Most recent activity
-
i just tested my seeed grove moisture sensor with success, and a few notes:
- need to convert from the sensor document values (0 - 950) to the espruino analogRead range (0-1)
- different values depending on battery power vs usb. not sure how much the values will change over the life of the battery. sensor in water from the battery was .47, and from usb was .55
- in order to use the sensor from the grove shield, i had to put a jumper from the 3.3v to 5v pins, as the shield uses the 5v pin for power. the sensor works with 3.3v - 5v range, so this was acceptable
when i replace my full code i'll post in another thread
- need to convert from the sensor document values (0 - 950) to the espruino analogRead range (0-1)
-
i'm going to convert my shield arduino code to pixl anyway, just as an exercise. it was accurate on the arduino as a setup for my indoor plant starters, but it didn't have a sleep mode, and drained the batteries too quickly. i look forward to seeing how energy efficient the pixl can be with this setup.
-
the moisture sensor is only using 3 of the pins: vcc, gnd, sig. it's this one
http://wiki.seeedstudio.com/Grove-Moisture_Sensor/ -
here's the arduino code i'll try to convert to a pixl when i get home this weekend. it reads from a moisture sensor, and a temperature/humidity sensor, and displays the values to an rgb display. unfortunately i won't be able to change the display color based on the moisture level, but it will be a good test. in my case i'm using an arduino shield with a grove sensor kit, so it will be a good test on the pixl as a shield as well.
[#include](https://forum.espruino.com/search/?q=%23include) "Arduino.h" [#include](https://forum.espruino.com/search/?q=%23include) "Wire.h" [#include](https://forum.espruino.com/search/?q=%23include) <rgb_lcd.h> [#include](https://forum.espruino.com/search/?q=%23include) <TH02_dev.h> [#include](https://forum.espruino.com/search/?q=%23include) <stdio.h> [#include](https://forum.espruino.com/search/?q=%23include) <math.h> [#include](https://forum.espruino.com/search/?q=%23include) <TimeLib.h> [#include](https://forum.espruino.com/search/?q=%23include) <TimeAlarms.h> rgb_lcd lcd; const int button = 2; // connect a button const int buzzer = 3; // connect a buzzer // Test code for Grove - Moisture Sensor int sensorPin = A0; // select the input pin for the potentiometer int moisture = -1; // variable to store the value coming from the sensor7 int prec = 0; int buttonPress = 0; int displayOn = 1; void setup() { Serial.begin(9600); // declare the ledPin as an OUTPUT: pinMode(button, INPUT); //set button as an INPUT device pinMode(buzzer, OUTPUT); //set LED as an OUTPUT device // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Set the LCD background color setColor(); Serial.println("****TH02_dev demo by seeed studio****\n"); /* Power up,delay 150ms,until voltage is stable */ delay(150); /* Reset HP20x_dev */ TH02.begin(); delay(100); /* Determine TH02_dev is available or not */ Serial.println("TH02_dev is available.\n"); Alarm.timerRepeat(5, readSensors); Alarm.timerRepeat(60, displayOff); } void loop() { buttonPress = digitalRead(button); //read the status of the button if( buttonPress && !displayOn ) { lcd.display(); displayOn = 1; setColor(); } //digitalWrite(buzzer, btn); Alarm.delay(10); } void readSensors() { Serial.println("Reading sensors"); // read the value from the sensor: moisture = analogRead(sensorPin); Serial.print("Moisture = " ); Serial.println(moisture); float temper = TH02.ReadTemperature(); Serial.println("Temperature: "); Serial.print(temper); Serial.println("C\r\n"); float humidity = TH02.ReadHumidity(); Serial.println("Humidity: "); Serial.print(humidity); Serial.println("%\r\n"); char message1[16]; char message2[16]; float ftemp = 1.8*temper + 32; long t = lround(ftemp); int tm = int((ftemp-floor(ftemp))*100)%100; long h = lround(humidity); int hm = int((humidity-floor(humidity))*100)%100; long m = moisture; sprintf(message1, "%ld.%dF, %ld.%dRH", t, tm, h, hm); Serial.println(int((temper-floor(temper))*100)%100); setColor(); lcd.clear(); lcd.setCursor(0,0); lcd.print(message1); lcd.setCursor(0,1); sprintf(message2, "Moisture: %3ld", m); lcd.print(message2); } void displayOff() { if( buttonPress ) { buttonPress = 0; } else { lcd.noDisplay(); lcd.setColorAll(); displayOn = 0; } } void setColor() { if( displayOn ) { if( moisture < 0 ) { lcd.setColorAll(); } else if( moisture < 300 ) { lcd.setColor(RED); } else if( moisture < 650 ) { lcd.setColor(GREEN); } else { lcd.setColor(BLUE); } } }
-
-
-
i'm hoping to get my first complete working version of a synthesizer using a few micro controllers, and a puck as a midi controller. it will use the light sensor as a theremin, and the button as a wobble controller. i also added a 20 watt per channel stereo amplifier shield, so it can fill a room with sound.
i'll add some details when back from my business trip this week.