Author Topic: DIY "GREEN DOT" Data Logger  (Read 94303 times)

0 Members and 1 Guest are viewing this topic.

Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: DIY "GREEN DOT" Data Logger
« Reply #275 on: April 02, 2017, 08:37:37 PM »
It was a joke, actually.  But, my smoker IS connected to the Internet!  You have no idea how useful that is while waiting for the "stall" on a Boston Butt to end.  I can be out in the fishing boat and the app notifies me to return to the dock to deal with BBQ.  Just because some "guru" says the IoT is not understood by many doe not mean it cannot have value.

regardless, my point on Davis is still valid: the logger is archaic (but it goes nicely with the circa 70's console)
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline torkelmj

  • Contributor
  • ***
  • Posts: 145
    • My weather station, etc.
Re: DIY "GREEN DOT" Data Logger
« Reply #276 on: April 05, 2017, 11:52:01 AM »
Maybe the minority should think twice next time before creating a headache for the majority, definitely not appreciated.   

That's one view of the world. I beg to differ.

Offline torkelmj

  • Contributor
  • ***
  • Posts: 145
    • My weather station, etc.
Re: DIY "GREEN DOT" Data Logger
« Reply #277 on: July 06, 2017, 11:59:59 AM »
hi,
My Vue is #6250 and Mfg code of ME18041xxxx.  'VER' returns May 1 2012. 'NVER' returns 3.0.

this is C source code for a funny experiments.
Code: [Select]
/*
 * compiler: Microchip XC8
 *
 *    PIC12F1822
 *     +--+ +--+
 * VCC |1  ~  8| GND
 *     |2     7| SDO
 *     |3     6| SCK
 *  SS |4     5| SDI
 *     +-------+
 */

// ... ... ...



Did anyone successfully implement & run this program?

I'm attempting to move from the AVR world to the PIC universe but I can't get this simple program to work as expected. While it works as intended when hooked up to a BusPirate, it certainly doesn't unlock the VP2 console (resulting in the "PLL NOT LCK" console message... which I believe refers to the radio/CC1021 configuration which also takes place on the same SPI bus).

I'm making ONE change to the original code, namely the LVP=ON pragma in order to use the Curiosity board programmer.

Offline kobuki

  • Forecaster
  • *****
  • Posts: 838
Re: DIY "GREEN DOT" Data Logger
« Reply #278 on: July 06, 2017, 12:20:26 PM »
I'm attempting to move from the AVR world to the PIC universe ...
Well, I'm aware this is not really on topic, but still...

May I ask, why? Isn't the generally accepted approach is to choose the most appropriate tool (chip, vendor, etc.) for a given purpose? Of course, considering other constraints, like available support (which tends to be huge for AVR, thanks mainly to the Arduino), accumulated skill level, ease of use, available compilers and tools, accessibility, etc. In other words, what does the PIC do for you that the AVR doesn't? I'm not defending any, but I must note that accessibility and support makes the AVR(/Arduino) side incomparably easier to use. Also, fun fact: Microchip now owns both the "world" and the "universe" as well ;)

Offline torkelmj

  • Contributor
  • ***
  • Posts: 145
    • My weather station, etc.
Re: DIY "GREEN DOT" Data Logger
« Reply #279 on: July 06, 2017, 01:06:01 PM »
It seems that the 8-pin ATTinys don't support SPI in mode 3. The VUEs seem to be picky about this.

Offline kobuki

  • Forecaster
  • *****
  • Posts: 838
Re: DIY "GREEN DOT" Data Logger
« Reply #280 on: July 06, 2017, 01:07:18 PM »
Ah. Strong argument.

Offline kashima

  • Member
  • *
  • Posts: 3
Re: DIY "GREEN DOT" Data Logger
« Reply #281 on: July 07, 2017, 12:29:54 AM »
Did anyone successfully implement & run this program?

Yes, it is working on my vantage vue.
I have wrote the HEX to the PIC using a PIC Start Plus.

HEX file are follows:

 [ You are not allowed to view attachments ]
« Last Edit: July 07, 2017, 12:32:58 AM by kashima »

Offline torkelmj

  • Contributor
  • ***
  • Posts: 145
    • My weather station, etc.
Re: DIY "GREEN DOT" Data Logger
« Reply #282 on: July 07, 2017, 02:55:55 AM »
Thanks. I'll just have to keep digging into this.
Again, my only change to the code is enabling low-voltage programming. Somehow the SS line seems to be pulled low way too early.

Offline night303

  • Member
  • *
  • Posts: 3
Re: DIY "GREEN DOT" Data Logger
« Reply #283 on: April 18, 2018, 01:56:01 PM »
Hello guys, my first post, but not first time I'm on this forum :)

During time I found some valuable information about Davis' v3 interface here, and devised few of my own solutions that I implemented successfuly on 5+ Davis Vantage Vue and Vantage Pro stations that operate 24/7 for years. So let me share that with you.

I read great PDF about Davis v3 protocol (http://meteo.annoyingdesigns.com/DavisSPI.pdf) by torkelmj and decided to make v3 emulator presented in that document. So I bought few ATTiny85 chips, already had programmer, and as base board I used interface board by belfryboy and simplified it. To skip USB->TTL->RS232->TTL conversion I reduced it to USB->TTL, reducing the cost and complexity, while keeping communication in perfect order. Also, since Davis' proprietary software interface costs money, I use Cumulus to stay in free software&hardware domain.

My design uses cheap USB->TTL cable from eBay, it's tested with Windows7 and Windows10 with latest updates and it works fine, it uses Prolific PL2302HX chip, and drivers are available from Prolific site. If it shows exclamation mark in Device Manager just reboot computer and it will work. Also I got info that it works with Raspberry Pi, but didn't tested it myself.
Can be bought here for 1.5 USD (link to specific seller is just for picture reference, you can buy from any seller, there are plenty on eBay offering exactly this same cable) : https://www.ebay.com/itm/USB-To-RS232-TTL-UART-PL2303HX-Auto-Converter-USB-to-COM-Cable-Adapter-Module/201539573206 My board has three pins that connects to this cable marked with letters on solder mask (G-green, W-white, B-black) for easier connecting.

Boards can be ordered directly from OSHPark or downloaded and made in any PCB factory you like, I designed board and put open-source-hardware mark, feel free to improve it if you like, and hopefully share design with others. If someone wants schematic and board in Eagle format, I can attach them. Just board is here : https://oshpark.com/shared_projects/M0mczaXC

Software in ATTiny is compiled from Bascom sources from above mentioned PDF, they are work of user watson from this forum. I'm attaching HEX files, but important thing is that AVR hex doesn't contain fuse bits information so you will have to specify them while programming chip. They are : Lock : 0xFF, FuseLow : 0xC1, FuseHigh : 0xDF, FuseExtended : 0xFF. It is important to program them correctly, else program won't work. For me both constant and random versions of firmware worked, but to be sure use constant version.

Besides ATTiny85, you will need : 1k or 470R resistor in SMD 0805 format, 0.1uF ceramic capacitor in SMD 1206 format and 3v Zener diode in SMD MINIMELF format. Capacitor is used as bypass cap, actually not needed in this application, but I put it for a good practice. Resistor and Zener are used to clamp 5V from USB->TTL cable to 3V, it worked for me even with 5V, but for a good practice it's better to clamp voltage as microcontroller in Davis operates at 3V. Only remaining part is 2x10 female header with 2mm pitch. Original data logger uses header that is a bit longer than ones I could find, by not pressing it directly to board, but soldering it with 1mm space between header plastic and board will do the trick and header will go firmly into expansion port.

So that's my solution, all for around 10 bucks. Once again, many many thanks to all users from this forum that made this interface possible, especially three mentioned above. Great work guys!

 [ You are not allowed to view attachments ]   [ You are not allowed to view attachments ]

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1308
  • BismarckWeather.net
    • BismarckWeather.net
Re: DIY "GREEN DOT" Data Logger
« Reply #284 on: April 18, 2018, 05:02:51 PM »
After working with the Software Designed Radio's with the NOAA weather radio, I wish I was smart enough to combine a SDR to retrieve the Davis ISS signal, and combine it with a Raspberry PI.  Basically turn the PI into a Weather Link IP.  In short, a replacement for a full console and data logger.

Only other issue is that you would need to add an external barometer and temp gauge to truly match what a console does.

Alas, I'm not a programmer. 
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline vreihen

  • El Niņo chaser
  • Forecaster
  • *****
  • Posts: 1216
  • K2BIG
Re: DIY "GREEN DOT" Data Logger
« Reply #285 on: April 18, 2018, 05:39:48 PM »
Some of the SDR heavy lifting has already been done.....

https://github.com/bemasher/rtldavis
WU Gold Stars for everyone! :lol:

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1308
  • BismarckWeather.net
    • BismarckWeather.net
Re: DIY "GREEN DOT" Data Logger
« Reply #286 on: April 19, 2018, 09:12:37 AM »
My idea was to basically create a replacement for the Virtual VP program.  Have a PI receive the data via SDR.  Then have a small database running on the PI.  Have it dish out the live data just like Virtual VP did.  Ideally via IP and multiple ports, and possible a serial driver.

Then have the data base store a history, basically like the data logger.  But also keep a history of when the last communication a particular port handed out the data.  Have a couple of weeks worth of data similar to what VVP could have done.

Like I said, I'm not a programmer.  But if you'd combine a copy of weewx or Cumulus MX on the same machine, you'd have a potent little device.  And you'd run it a lot cheaper than a second console and logger.  But you'd still need a barometer connected to it as well as probably an inside temp if you truly are replacing the console.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline pfletch101

  • Forecaster
  • *****
  • Posts: 329
    • Personal Website
Re: DIY "GREEN DOT" Data Logger
« Reply #287 on: April 19, 2018, 10:22:56 AM »
Like I said, I'm not a programmer.  But if you'd combine a copy of weewx or Cumulus MX on the same machine, you'd have a potent little device.  And you'd run it a lot cheaper than a second console and logger.  But you'd still need a barometer connected to it as well as probably an inside temp if you truly are replacing the console.

Assuming that you already have the Pi and an SDR dongle, you can get and use an Ambient Temp/humidity sensor (which can be located where you want it, rather than being constrained by the location of the Pi, with its power supply) for just over $10.00, and a decent barometer sensor to wire to the Pi for about the same amount. Some programming would be required, of course.  :-)
Vantage Pro 2+ connected to Raspberry Pi running weewx by means of Meteo-Pi - data incorporated in domestic energy production (PV) and use monitoring system.

Offline pfletch101

  • Forecaster
  • *****
  • Posts: 329
    • Personal Website
Re: DIY "GREEN DOT" Data Logger
« Reply #288 on: April 19, 2018, 09:14:36 PM »
Some of the SDR heavy lifting has already been done.....

https://github.com/bemasher/rtldavis

Sadly, this project appears to be a 'work in progress' that stopped progressing a couple of years ago.
Vantage Pro 2+ connected to Raspberry Pi running weewx by means of Meteo-Pi - data incorporated in domestic energy production (PV) and use monitoring system.

Offline vreihen

  • El Niņo chaser
  • Forecaster
  • *****
  • Posts: 1216
  • K2BIG
Re: DIY "GREEN DOT" Data Logger
« Reply #289 on: April 20, 2018, 07:04:42 AM »
Note that I said "some" of the heavy lifting.  Unlike many of the consumer 433Mhz stations, Davis uses frequency hopping that adds an extra layer of complexity when trying to snag packets with an SDR.

IIRC, the above code can follow the frequency hops and collect data, but is missing the decoder part.  Since Boris/MeteoStick/MB-Pro have figured this out, it is obviously possible to decode the information.  My uneducated guess would be that Davis sends the exact same packet data over the air that they send to a wired console, so it may just be a matter of finding any progress made on decoding that and joining it to the SDR code.....
WU Gold Stars for everyone! :lol:

Offline kobuki

  • Forecaster
  • *****
  • Posts: 838
Re: DIY "GREEN DOT" Data Logger
« Reply #290 on: April 20, 2018, 07:45:37 AM »
On the air packet format and transmit scheduling is the same as on wire. The code in the mentioned repo can decode the radio packets and there are already a handful of solutions to make use of them, including my own here. If someone adept in golang could come up with a daemon that can serve the packets via eg. a simple tcp or unix socket interface (based on the bemasher repo), I'm willing to add handler code to my fork of the weewx driver.

Offline pfletch101

  • Forecaster
  • *****
  • Posts: 329
    • Personal Website
Re: DIY "GREEN DOT" Data Logger
« Reply #291 on: April 20, 2018, 10:24:34 AM »
In my (admittedly fairly brief) tests, with an antenna located within a few inches of a Davis console which shows excellent reception, and a good-quality SDR (that works very well with Ambient TH sensors), the software was apparently only able to detect/decode occasional transmissions. Life is too short - for me, at least - to try to use/debug/modify unsupported software in a language that I don't 'speak'. YMMV.

I will be sticking to downloading the data from the USB logger in my console, for now.
Vantage Pro 2+ connected to Raspberry Pi running weewx by means of Meteo-Pi - data incorporated in domestic energy production (PV) and use monitoring system.

Offline kobuki

  • Forecaster
  • *****
  • Posts: 838
Re: DIY "GREEN DOT" Data Logger
« Reply #292 on: April 21, 2018, 06:39:55 AM »
So this solution doesn't look reliable with the existing software. Too bad...

Offline vreihen

  • El Niņo chaser
  • Forecaster
  • *****
  • Posts: 1216
  • K2BIG
Re: DIY "GREEN DOT" Data Logger
« Reply #293 on: April 21, 2018, 08:20:04 AM »
So this solution doesn't look reliable with the existing software. Too bad...

For some background, I have only had my Davis VP2 for about a month now, after wrestling with various hacks to collect data from other consumer-oriented stations for years.

The only reason why I have not pursued these Davis hack setups any further is because of what I learned above.  If the SDR locks up or overflows the USB bus, you lose data.  If you have to shut down your logging computer with a serial or USB-connected console, you lose data.  Starting to see a recurring theme here?  I lost three weeks of data due to an unexpected hospital stay, combined with a USB bus lockup with an SDR.

My eyes were opened when I was setting up a genuine Davis USB logger a few weeks ago.  I needed to shut down my new weewx Raspberry Pi to install a realtime clock, and I was *floored* when I saw the weewx Vantage driver backfill data from the time that the computer was down thanks to its internal memory!   Made me realize that Davis calls the thing a "logger" because it has memory to LOG data...even when the connected device is offline.  Maybe data continuity means less to others, but the Davis logger is worth the price to me compared with options that do not have replay capabilities if the connected computer is down.

I do have the desire to crack the Davis wired console code one day, to put a Raspberry Pi or NodeMCU inside a wired VP2 ISS to make a wifi weather station.  Purely for the technical challenge, not something that I would ever personally use unless I could obtain the Davis logger's reliability levels.....
WU Gold Stars for everyone! :lol:

Offline kobuki

  • Forecaster
  • *****
  • Posts: 838
Re: DIY "GREEN DOT" Data Logger
« Reply #294 on: April 21, 2018, 08:41:56 AM »
My receiver and the weewx driver has been working stable for years. Currently the receiver has a bug that prevents correct reception of US channels and since I only have EU equipment I can't fix it easily. Just give it a try (or another one based on mine) sometime. It doesn't have log memory, though. It's running mostly on RPi3 devices in the wild and some of them are running from UPS solutions so they don't lose data on blackouts. The driver has been extensively tuned by me and also its upstream for the best precision we could achieve using available formulas and our own tests. There are ports for other MCUs and IIRC even for ESP8266-based devices. You can easily adapt any of those for cabled connections if you want since they use the same packet format as the RF ones.

Offline sjjh

  • Member
  • *
  • Posts: 3
Re: DIY "GREEN DOT" Data Logger
« Reply #295 on: June 26, 2018, 04:36:23 PM »
Hi, first post here. :)

We're trying to follow the different guides in this forum to create a DIY data logger. We use the pcb from night303 with an ATTINY85-20SU-ND as described in the PDF by  Torkelmj. To program the ATTINY85 we use an Arduino UNO and the program described by JoeBean. Unfortunately JoeBean used an AT45DB011 chip that seems to have a different pin assignment than the ATTINY85. We're thus a little unsure how to connect the ATTINY85 to the Ardunio. We came up with following set-up, but it seems not to work (no connection and out of sync-errors appear in the Ardunio sketch output, after changing pin 7 and 12 there's no output at all anymore, we might just have bricked the chip):
Code: [Select]
    AT45DB011D  ------------  ARDUINO
    1 (SI/MOSI) ------------  Pin 11
    2 (SCK)     ------------  Pin 13layout
    3 (RESET)   ------------  Pin 8
    4 (CS)      ------------  Pin 10
    5 (WP)      ------------  Pin 7
    6 (VCC)     ------------  3.3V
    7 (GND)     ------------  Ground
    8 (SO)      ------------  Pin 12


    ATTINY85-20SU-ND -------  ARDUINO
    1 (RESET)   ------------  Pin 8
    2 (WP)      ------------  Pin 7 (??)
    3 (CS)      ------------  Pin 10 (?)
    4 (GND)     ------------  Ground
    5 (SI/MOSI) ------------  Pin 11
    6 (SO)      ------------  Pin 12 (??)
    7 (SCK)     ------------  Pin 13
    8 (VCC)     ------------  5V

Can anybody confirm the pin assignment? Or give a hint how to proceed?

Thanks in advance!
Simon

Offline docbee

  • Forecaster
  • *****
  • Posts: 853
    • smartbedded
Re: DIY "GREEN DOT" Data Logger
« Reply #296 on: June 27, 2018, 04:53:50 PM »
ATTINY85 and AT45DB011 are completely different things IMHO. While the AT45DB011 is a serial data flash storage chip with a security register and some write once regions the ATTINY85 is a computing device that tries to trick the console by imitating the signal behavior expected by the console.

So the pin layout is not the main problem to solve when trying to use one as a drop-in replacement for the other. But may be I am missing something here. The most compatible way to Davis green dot is of course when you go the AT45DB011 route, but it requires to get a grip on those chips, which are EOL in the meantime.
founder of smartbedded.com - home of meteohub, meteoplug, meteobridge, meteostick

Offline sjjh

  • Member
  • *
  • Posts: 3
Re: DIY "GREEN DOT" Data Logger
« Reply #297 on: June 27, 2018, 05:42:05 PM »
Ah, damn it. Thx for your reply. So if I understand it correctly either we would need to find a successor of the AT45DB011 and hope that it works as well (I mean, Davis must continue to use some chip as well), or we would need to port the code printed in the PDF to an Arduino sketch.

//Edit: The replacement for the AT45DB011 seems to be the AT45DB021E [1] which might be compatible to it [2] and still seems to be available (e.g. via mouser). But as we bought the above mentioned PCB [3] and the AT45DB021E is not compatible to the ATTINY85 I'm wondering if we actually could use the AT45DB021E at all anyway? Anybody an idea? Thx!

[1] http://www.adestotech.com/pcn/pdf023.pdf
[2] https://www.adestotech.com/wp-content/uploads/doc8789.pdf
[3] https://oshpark.com/shared_projects/M0mczaXC
« Last Edit: July 06, 2018, 06:19:51 AM by sjjh »

Offline night303

  • Member
  • *
  • Posts: 3
Re: DIY "GREEN DOT" Data Logger
« Reply #298 on: August 08, 2018, 05:31:24 PM »
Hi, first post here. :)

We're trying to follow the different guides in this forum to create a DIY data logger. We use the pcb from night303 with an ATTINY85-20SU-ND as described in the PDF by  Torkelmj. To program the ATTINY85 we use an Arduino UNO and the program described by JoeBean. Unfortunately JoeBean used an AT45DB011 chip that seems to have a different pin assignment than the ATTINY85. We're thus a little unsure how to connect the ATTINY85 to the Ardunio. We came up with following set-up, but it seems not to work (no connection and out of sync-errors appear in the Ardunio sketch output, after changing pin 7 and 12 there's no output at all anymore, we might just have bricked the chip):
Can anybody confirm the pin assignment? Or give a hint how to proceed?

Thanks in advance!
Simon

As docbee said, ATTiny is microcontroller and AT45DB011 is flash chip, so they're completely different kind of chips.

For programming ATTiny I used MiniPro programmer, but it can also be programmed with Arduino. Check out this link :
https://www.instructables.com/id/Attiny-Programmer-using-Arduino-UNO/

Note that version with ATTiny doesn't give you data logger functionality, it just unlocks UART port so Davis station can be used with USB-UART cable for connecting to Cumulus (tested) and probably other software as well.


Offline sjjh

  • Member
  • *
  • Posts: 3
Re: DIY "GREEN DOT" Data Logger
« Reply #299 on: August 09, 2018, 04:01:55 AM »
Thanks for your reply. We were aware of the missing data storing capability of the data logger using an ATtiny85, but as we intended to connect it to an constantly running Rasperry Pi running Weewx we believed that this shouldn't be a problem.
Anyway, In the meantime we looked into programming the ATtiny85 with the Arduino Uno -- and it unfortunately seemed more complicated than I hoped. I started porting the Basic code published by Torkel in his PDF to an Arduino sketch (see below), but struggled with the communication part. The ATtiny85 doesn't support SPI, but only USI. We tried to use ATTinyCore to add support for the ATtiny85 to the Arduino Uno, but it only supports SPI master and not slave mode. I wasn't able to find an Arduino Uno SPI slave library using USI for the ATtiny85. As I have no experience in programming micro controllers what so ever and the data logger is needed rather quickly, we went for the easier route and ordered one from belfryboy. Maybe we'll try to build our own later on... If anybody is able to bring it further, I'd be happy to get to know about it.
Simon

Code: [Select]
/*
  Unlock the Davis VP2/Vue console serial line using the ATtiny85 and a
  random device ID. Using algorithm as described by WXForum.net user
  "watson" on November 28, 2013: http://www.wxforum.net/index.php?topic=18110.msg200376.

  Code based on a programm by Torkel M. Jodalen <tmj@bitwrap.no> in revision from 2013-11-30
  available at http://wx.annoyingdesigns.com/DavisSPI.pdf

  Ported to Arduino Sketch by Simon Harhues (2018-07-06 to 2018-07-16 )

  See example for SPI slave support:
  https://gist.github.com/Weathergadget/b96255e5ec700a15e42c4c1497ec506b#file-attiny_spi_slave-ino
  https://weathergadget.wordpress.com/2016/05/19/usi-spi-slave-communication/

  https://avrhelp.mcselec.com/index.html?using_usi_universal_serial_int.htm

 
  Pin assignment of ATtiny85 for ISP communciation (https://github.com/SpenceKonde/ATTinyCore):
  Note: Davis Console acts as master, data logger as slave
  1:  Reset   8:  VCC
  2:  xy      7:  SCK
  3:  xy      6:  MISO/DO [as slave]
  4:  GND     5:  MOSI/DI [as slave]
*/


// Static look-up table for security register
u8 const GreenDot_Table[256] =
{
0x00, 0x04, 0x08, 0x0C, 0x10, 0x14, 0x18, 0x1C, 0x21, 0x25, 0x29, 0x2D, 0x31, 0x35, 0x39, 0x3D,
0x46, 0x42, 0x4E, 0x4A, 0x56, 0x52, 0x5E, 0x5A, 0x67, 0x63, 0x6F, 0x6B, 0x77, 0x73, 0x7F, 0x7B,
0x8C, 0x88, 0x84, 0x80, 0x9C, 0x98, 0x94, 0x90, 0xAD, 0xA9, 0xA5, 0xA1, 0xBD, 0xB9, 0xB5, 0xB1,
0xCA, 0xCE, 0xC2, 0xC6, 0xDA, 0xDE, 0xD2, 0xD6, 0xEB, 0xEF, 0xE3, 0xE7, 0xFB, 0xFF, 0xF3, 0xF7,
0x18, 0x1C, 0x10, 0x14, 0x08, 0x0C, 0x00, 0x04, 0x39, 0x3D, 0x31, 0x35, 0x29, 0x2D, 0x21, 0x25,
0x5E, 0x5A, 0x56, 0x52, 0x4E, 0x4A, 0x46, 0x42, 0x7F, 0x7B, 0x77, 0x73, 0x6F, 0x6B, 0x67, 0x63,
0x94, 0x90, 0x9C, 0x98, 0x84, 0x80, 0x8C, 0x88, 0xB5, 0xB1, 0xBD, 0xB9, 0xA5, 0xA1, 0xAD, 0xA9,
0xD2, 0xD6, 0xDA, 0xDE, 0xC2, 0xC6, 0xCA, 0xCE, 0xF3, 0xF7, 0xFB, 0xFF, 0xE3, 0xE7, 0xEB, 0xEF,
0x31, 0x35, 0x39, 0x3D, 0x21, 0x25, 0x29, 0x2D, 0x10, 0x14, 0x18, 0x1C, 0x00, 0x04, 0x08, 0x0C,
0x77, 0x73, 0x7F, 0x7B, 0x67, 0x63, 0x6F, 0x6B, 0x56, 0x52, 0x5E, 0x5A, 0x46, 0x42, 0x4E, 0x4A,
0xBD, 0xB9, 0xB5, 0xB1, 0xAD, 0xA9, 0xA5, 0xA1, 0x9C, 0x98, 0x94, 0x90, 0x8C, 0x88, 0x84, 0x80,
0xFB, 0xFF, 0xF3, 0xF7, 0xEB, 0xEF, 0xE3, 0xE7, 0xDA, 0xDE, 0xD2, 0xD6, 0xCA, 0xCE, 0xC2, 0xC6,
0x29, 0x2D, 0x21, 0x25, 0x39, 0x3D, 0x31, 0x35, 0x08, 0x0C, 0x00, 0x04, 0x18, 0x1C, 0x10, 0x14,
0x6F, 0x6B, 0x67, 0x63, 0x7F, 0x7B, 0x77, 0x73, 0x4E, 0x4A, 0x46, 0x42, 0x5E, 0x5A, 0x56, 0x52,
0xA5, 0xA1, 0xAD, 0xA9, 0xB5, 0xB1, 0xBD, 0xB9, 0x84, 0x80, 0x8C, 0x88, 0x94, 0x90, 0x9C, 0x98,
0xE3, 0xE7, 0xEB, 0xEF, 0xF3, 0xF7, 0xFB, 0xFF, 0xC2, 0xC6, 0xCA, 0xCE, 0xD2, 0xD6, 0xDA, 0xDE
};


// the setup function runs once when you press reset or power the board
void setup() {
  u8 const OptCode_ChipStatus       = 0xD7;   // optcode to request chip status
  u8 const Reply_ChipStatus         = 0x8C;   // response to chip status request
  u8 const OptCode_SecurityRegister = 0x77;   // optcode to request security register value
  //the following is probably not needed (according to Torkels PDF)
//  u8 const OptCode_ManufacturerID_DataDensity = 0x9F; // optcode to request manufacturer id (0x1F) and data density (0x22)
 
  // The 128 byte one time programmable security register
  // Bytes  0 -   2: fixed (value seems to not matter)
  // Bytes  3 -  64: calculated value (derived from devide id)
  // Bytes 64 - 127: device id (we'll use a random one here)
  u8 Security_Register[128];
 
  // Fill fixed values, bytes 0-2
  Security_Register[0] = 0x00; // or whatever you want
  Security_Register[1] = 0x00; // or whatever you want
  Security_Register[2] = 0x07; // or whatever you want
 
  // Fill in a random device ID, bytes 64-127
  for (int i=64;i<128;i++){
    Security_Register[i] = (u8)random(256);
  }
  // Fill in appropiate calculated security register values, bytes 3-63
  u8 value;
  for (int i=3;i<64;i++){
    value = (u8)(Security_Register[64 + n] + n); //device ID starts at byte 64 of security register
    Security_Register[i] = GreenDot_Table[value];
  }



  // Wait for console to communicate with us, the data logger
 
  //ToDo: to request optcode 0xD7 reply with chip status (0x8C)
 
  //ToDo: to request optcode 0x77 reply with security register
  for (int i=0;i<128;i++){
    //write Security_Register[i];
  }
  // see examples
  // see: https://create.arduino.cc/projecthub/arjun/programming-attiny85-with-arduino-uno-afb829
}

// the loop function runs over and over again forever
void loop() {
}

 

anything