Skip to content

Instantly share code, notes, and snippets.

@atotto
Created December 19, 2016 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atotto/f7f2eecaf6fb9359c1422aa23301011a to your computer and use it in GitHub Desktop.
Save atotto/f7f2eecaf6fb9359c1422aa23301011a to your computer and use it in GitHub Desktop.
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);
}
@atotto
Copy link
Author

atotto commented Dec 19, 2016

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