-
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); } } }
-
-
-
-
this data logging shield would be very convenient: https://www.adafruit.com/product/1141
-
i installed polyfill, and it allows the example web bluetooth pages to work online and locally. when i try to use espruino.com/ide it finds the bluetooth devices but crashes the bluetooth adapter when connecting to a puck. it says it can't get the board configuration, but it connects with no prompt available. again i can send code to the puck, and it loads, but an error follows saying that it can't get a prompt, and it's trying to recover.
i haven't gotten to testing flow control yet, but since web bluetooth is working locally on windows with node express, then i'll use this opportunity to see what kind of dashboard i can get going. i'll continue more updates in a different thread.
at least now i can program my hacking board remotely, and not need to be connected to the internet. now i can hack from a park just as easily as a coffee shop :)
-
-
-
this is where it gets interesting, and i really just started experimenting with what works. out of the box these work with the uart friend and the wifi paired:
- Adafruit Bluefruit LE android app
- This example http://www.espruino.com/Puck.js+Web+Bluetooth
- The same example running locally on an rpi 3 b+ with express https
the web bluetooth ide sort of works from my rpi with this setup. it connects to the uart friend, but doesn't get a proper prompt setup. i can upload code from the right side, and use the repl, but it gives errors. interestingly, i can connect the web bluetooth ide to the uart, and the windows native ide directly to the wifi, and see console output on both sides :)
the windows native ide sees the uart friend but fails to connect. it does connect to my puck just fine.
the web bluetooth ide on windows behaves similarly to pucks and the uart friend, in that it will connect, but give no prompt. and then sometimes it just doesn't work at all on windows in chrome.
ultimately i'd like to have a local web bluetooth ide working. it looks doable on my rpi 3 b+. i haven't tried it yet on windows. the web bluetooth examples seem to have problems loading the bluetooth adapter in chrome on windows as well.
frustrating world for web bluetooth development at the moment.
- Adafruit Bluefruit LE android app
-
-
-
-
Is it possible to use the NRF module on an espruino wifi? I have an LE UART Friend https://www.adafruit.com/product/2479 and it is connected to my espruino on B5, B6, B7. Works great in UART and CMD mode, but it would be awesome to use the NRF module to interface with it. That module doesn't seem to be included with the wifi build.
-
-
-
-
ok, this is working now with espruino as the ws client, and ws server. getPage() is working as well.
i do have an additional question: when espruino is the ws client, and i send a message from the node.js server, it shows up as a rawData event as well as a message event. is this expected?
wsConnect()
=undefined
RAW: HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: NRGmTTLwn7B71D1ZNRdkobCXs/0=
Sec-WebSocket-Protocol: echo-protocol
Handshake Success
Connected to server
RAW: something
MSG: something -
which build are you looking at? the larger remaining problem is the espruino not working as a websocket server, as documented in the github issues https://github.com/espruino/Espruino/issues/1405.
i'll test again if you let me know which build to look at.
-
-
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.