-
• #27
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)
-
• #28
Good news!
Even got it work on a esp32 with espruino
Here is the codevar high = 0.5; var low = 0.0; function map_value(val, in_min, in_max, out_min, out_max){ var result = (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; if(result < out_min) { return out_min; } else if(result > out_max) { return out_max; } return result; } function onTimer() { var h = analogRead(D35); // D35 is a adc-port (analog to digital converter) var hp = map_value(h, low, high, 0, 100); var percentage = hp.toFixed(0)+"%"; console.log("Soil moister", percentage); } // Update soil moister every 2 seconds setInterval(onTimer, 2000); // Update soil moister immediately onTimer();
To bad there are no bluetooth support yet :(
-
• #29
Ahh - but there is now Bluetooth support for the esp32!
-
• #30
Nice! I just asumed because of the documentation sudgested otherwise :)
-
• #31
It's still pretty beta, but with a bit of work you can get it doing simple advertising stuff :)
-
• #32
Nice
-
• #33
Im trying to broadcast ble data with the esp32. But its not implemented yet the console informs me. Didnt you guys say it worked now?
var high = 0.5; var low = 0.0; function map_value(val, in_min, in_max, out_min, out_max){ var result = (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; if(result < out_min) { return out_min; } else if(result > out_max) { return out_max; } return result; } function onTimer() { var h = analogRead(D35); var hp = map_value(h, low, high, 0, 100); var percentage = hp.toFixed(0)+"%"; NRF.setServices({ 0xBCDE : { 0xABCD : { value : percentage, readable : true } } }); console.log("Soil moister", percentage); } // Update soil moister every 2 seconds setInterval(onTimer, 2000); // Update soil moister immediately onTimer();
Console
Soil moister 0% WARNING: has connected not implemented yet
-
• #34
I think I said it was very beta. You can get advertising going with some work - maybe with
NRF.wake()
? It'll still give you warnings all over the place.If you have issues with it post on the ESP32 forum though. ESP32 isn't something I can provide any support for.
-
• #35
Ok, thanks I will try that.
I c. I just changed the ”high” variable to a lower value and it worked. Thanks for the help! :)