-
@allobjects.. Ok, i think I get it. How do I access sensorObject to gather the values when using code:
var sensorObject = { "restempvalue" : 0, "phvalue" : 0, "ecvalue" : 0 };
Nevermind... I read over your posts again.. I was just a bit confused, before. Thanks for the informative response.
-
My goal is to calculate sensor readings and then save them to a JSON object then console.log output a specific value. I'm not sure why I'm not able to access my json value. I keep getting error:
Uncaught Error: Field or method "restempvalue" does not already exist, and can't create it on undefined at line 153 col 10 sensorObj.restempvalue = val; ^
code:
var sensorReadings = { "restempvalue" : 0, "phvalue" : 0, "ecvalue" : 0 }; var sensorObj = JSON.parse(sensorReadings); function getAllSensorData() { /*restemp.takeReading(function(val) { console.log(val); }); ph.takeReading(function(val) { console.log(val); });*/ ec.takeReading(function(val) { sensorObj.restempvalue = val; console.log(val); }); }
-
@Gordon. That did the trick. Thanks
-
I'm getting undefined for resTempVal and undefined outputs before console.log(resTempVal); So, i'm assuming there's a small delay while taking the sensor reading and the variable resTempVal isn't set. Is there a way to wait until resTempVal gets set before I continue?
code:
Sensor.prototype.takeReading = function() { var a = this.sensorAddress; var c = this.cmdTable.Reading.R.cmd; var w = this.cmdTable.Reading.R.wait; var d = ""; var sensorStatus = ""; var sensorValue = ""; var captureSensorData = false; I2C1.writeTo(a, c); setTimeout(function () { d = I2C1.readFrom(a, 9); if (d.length > 0) { var dContent = d[0]; switch (dContent) { case 1: sensorStatus = 1; captureSensorData = true; break; case 255: sensorStatus = 255; break; case 254: sensorStatus = 254; break; case 2: sensorStatus = 2; break; } if (captureSensorData === true) { for (i = 1; i < d.length; i++) { sensorValue += String.fromCharCode(d[i]); } } captureSensorData = false; console.log(sensorValue); //<-- I get output return sensorValue; } }, w); }; var restemp = new Sensor("RES TEMP", "temp", 77); var ph = new Sensor("PH", "ph", 78); var ec = new Sensor("EC", "ec", 99); function getAllSensorData() { resTempVal = restemp.takeReading(); console.log(resTempVal); //<-- undefined } setInterval(function () { console.log("Taking Reading: "); getAllSensorData(); }, 5000);
-
-
I'm trying to receive a value from my temp sensor. Expect I'm receiving "77 r" (without quotes). I should be receiving a number value.
code:
I2C1.setup({scl:B8, sda:B9}); Serial2.setup(9600/*baud*/); var resTempVal = ""; var phVal = ""; var ecVal = ""; var ready = true; var alwaysTempCompensate = false; function Sensor(id, type, address) { this.sensorName = id; this.sensorType = type; this.sensorAddress = address; this.sensorRequireTempComp = false; this.resTempCal = { "clear" : { "cmd" : "Cal,Clear", "wait" : 300 }, "one" : { "cmd" : "Cal,n", "wait" : 1300 }, "query" : { "cmd" : "Cal,?", "wait" : 300 } }; this.phCal = { "clear" : { "cmd" : "Cal,Clear", "wait" : 300 }, "mid" : { "cmd" : "Cal,mid,7.00", "wait" : 1300 }, "low" : { "cmd" : "Cal,low,4.00", "wait" : 1300 }, "high" : { "cmd" : "Cal,high,10.00", "wait" : 1300 }, "query" : { "cmd" : "Cal,?", "wait" : 300 } }; this.ecCal = { "clear" : { "cmd" : "Cal,Clear", "wait" : 300 }, "dry" : { "cmd" : "Cal,dry", "wait" : 2000 }, "one" : { "cmd" : "Cal,one,n", "wait" : 1300 }, "low" : { "cmd" : "Cal,low,n", "wait" : 1300 }, "high" : { "cmd" : "Cal,high,n", "wait" : 1300 }, "query" : { "cmd" : "Cal,?", "wait" : 300 } }; this.cmdTable = { "Calibrate" : { //List of Calibration commands and timeout value. }, "Information" : { //Device Information }, "LED" : { //Enable / Disable or Query the LEDs "L0" : { "cmd" : "L,0", "wait" : 300 }, "L1" : { "cmd" : "L,1", "wait" : 300 }, "L?" : { "cmd" : "L,?", "wait" : 300 } }, "Reading" : { //Takes a single reading "R" : { "cmd" : "r", "wait" : 1000 } //Takes a single temperature compensated reading }, "Serial" : { //Switch back to UART mode }, "Sleep" : { //Enter low power sleep mode }, "Status" : { //Retrieve status information }, "Temperature" : { //Set or Query the temperature compensation "T" : { "cmd" : "T", "wait" : 300 }, //Where the temperature is any value; floating point, or int, in ASCII form "T?" : { "cmd" : "T,?", "wait" : 300 } //Query the set temerature }, "Factory" : { //Factory reset }, }; if (type == "temp") { this.cmdTable.Calibrate = this.resTempCal; //console.log(this.cmdTable.Calibrate); } if (type == "ph") { this.cmdTable.Calibrate = this.phCal; //console.log(this.cmdTable.Calibrate); this.sensorRequireTempComp = true; } if (type == "ec") { this.cmdTable.Calibrate = this.ecCal; //console.log(this.cmdTable.Calibrate); this.sensorRequireTempComp = true; } } Sensor.prototype.updateTempComp = function (temp) { this.cmdTable.Temperature.T.cmd = "T," + temp; }; Sensor.prototype.takeReading = function() { var a = this.sensorAddress; var c = this.cmdTable.Reading.R.cmd; var w = this.cmdTable.Reading.R.wait; var d = ""; var sensorStatus = ""; var sensorValue = ""; var captureSensorData = false; console.log(a + " " + c); I2C1.writeTo(a, c); setTimeout(function () { d = I2C1.readFrom(a, 9); if (d.length > 0) { var dContent = d[0]; switch (dContent) { case 1: //console.log("Success"); sensorStatus = 1; captureSensorData = true; break; case 255: sensorStatus = 255; break; case 254: sensorStatus = 254; break; case 2: sensorStatus = 2; break; } if (captureSensorData === true) { for (i = 1; i < d.length; i++) { //console.log(i + " = " + d[i]); sensorValue += String.fromCharCode(d[i]); } console.log(sensorValue); //<-----Outputs the value correctly } } captureSensorData = false; return sensorValue; //console.log(sensorValue); }, w); }; var restemp = new Sensor("RES TEMP", "temp", 77); var ph = new Sensor("PH", "ph", 78); var ec = new Sensor("EC", "ec", 99); function getAllSensorData() { resTempVal = restemp.takeReading(); return resTempVal; } setInterval(function () { console.log("Taking Reading: "); getAllSensorData(); }, 5000);
-
-
I plan to use the Pico Arduino adapter without the pullups and leave the resistor pads untouched since the shield that I would like to use already has pullups. The manufacturer of the shield specified that the shield ONLY operates at 5volts and could damage whatever it is hooked up. I plan to communicate via i2c...
Does the Pico's i2c bus operate at 5volts or only at 3volts but is 5volt tolerant?
-
-
@Gordon I spoke to soon. I switch cables and USB ports and I am still having the same issue. This will also be my second time reinstalling the drivers.
EDIT
Oops I forgot one crucial step: Unzip the file, run the executable, and then go to C:\Program Files (x86)\STMicroelectronics\Software\Virtual comport driver in Windows Explorer and double-click either dpinst_amd64.exe for 64 bit systems, or dpinst_x86.exe for 32 bit.Everything appears to be functioning properly again :-)
-
@Gordon Strange, everything seems to be functioning correctly now. My USB cable is most likely not functioning properly.
-
Driver worked well in Win 7 until I updated to Win 10. I didn't do a clean install of Windows 10, just an upgrade from 7 to 10. Plugged in a fresh Pico and saw the red light flash. I opened up the web IDE tried the normal way to connect and it said Connect failed. I tried a restart but same thing. So I checked Device manager and noticed:
-
-
Good point and I don't think the bartendro pcb will mount to this pump + motor: http://www.ebay.com/itm/24V-DC-Dosing-pump-Peristaltic-dosing-Head-Tube-For-Aquarium-Lab-Analytica-water/221974387648?_trksid=p2054502.c100229.m3211&_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20140505115423%26meid%3D445d49fd5ba94b688f54d7c72e56fa1a%26pid%3D100229%26rk%3D2%26rkt%3D7%26sd%3D321756321027
I'll research more after I finish the project that I'm currently working on. I'm still waiting for the ESPs to arrive from china.
-
@DrAzzy I was assuming that was the cap visible in the picture on their website.
I can purchase a pump + motor(24v) from ebay for about $8 and change from China. I'm not sure about the quality of the pump and motor though. A really nice quality made pump will cost a bloody fortune. -
I was at the hospital the other day and noticed a parasitical pump and wondered if I could use an Espruino to control it. Anyways,I stumbled upon the Bartendro from partyrobotics.com I believe the Bartendro uses the same "brains" as an Arduino and was wondering if replacing the "brains" with an Espruino is worth the hassle and time. Anyways, its not a project that I'm willing to attempt ATM. Its more of a curiosity of how much parts and the pcb will cost if I would to build my own instead of paying the 119$ for an already assembled product. I'm thinking the bulk of the 119$ price tag is due to research and development.
@Gordon You're right, its not a tiny surface mount device
@DrAzzy looks like a D SMD case Aluminum Electrolytic Capacitor; however, I'm not sure if there is another D SMD style case cap that I could confuse with what is required to use.
I uploaded the brd and sch files.
-
-
Quick update. Board status says shipped. I chose the free shipping method so who knows when the boards will arrive.
I will post more pictures and a better description once I assemble a prototype PCB.
With regards to wifi signal range... does the ESP-12E board have a connector for an option to use an external antenna?
-
Hey @JumJum How's the progress coming along?
-
I've been working on this project on and off for a few months now. Board has been sent to the dirtypcbs fab house already and I received my parts from digikey. However, I still need to purchase a few ESP12s. anyways.... here is the board pic. Also, board files are attached.
Thanks DrAzzy for the PCB design :-)
Stay tuned for more pictures and a better explanation of my project...
-
-
@stephaneAG very cool and thank you for your contribution :-) My current project is on hold at the moment, but I will definitely look into using that chip in the near future.
-
-
@DrAzzy ya, for vapes. I'll have to do a bit more research on this technology. I know (don't remember the source) that someone created a diy vape using an arduino.
@allObjects Thanks for that. I get it :-) I really like the flow of your code example/explaination.