Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Digispark LM61CIZ Temperature Sensor
#include <DigiUSB.h>
void setup()
{
pinMode(2, INPUT); // P2 = anolog input 1
pinMode(1, OUTPUT);
DigiUSB.begin();
}
void loop()
{
digitalWrite(1, HIGH);
int step;
float temp;
step = analogRead(1);
temp = (float)step*500.0/1024.0-60.0;
DigiUSB.print("{\"temp\":");
DigiUSB.print(temp);
DigiUSB.println("}");
digitalWrite(1, LOW);
DigiUSB.delay(1000);
}
Owner
atotto commented Dec 19, 2016 edited

blog http://atotto.hatenadiary.jp/entry/digispark_lm61_usb (lang=ja)

digispark-lm61ciz

$ sudo pip install pyusb
$ git clone https://github.com/digistump/DigisparkExamplePrograms.git --depth 1
$ cd DigisparkExamplePrograms/Python/DigiUSB/source
$ sudo python receive.py | jq .
{
  "temp": 23.98
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment