[SOLVED]Need help interpreting the serial output of a sensor #1823
Replies: 26 comments
-
Posted at 2019-06-22 by Robin Sat 2019.06.22 Hi @larry, garbled chars are usually a sign of baud rate mis-match. Would you please post results of
In the #1 post, it is indicated that a buffer containing ten hex values was returned. Is this the case with the current Pico script? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-22 by larry Here my small Node script, I've just connect de SDS011 to an USB to my computer (port COM8):
I've added a console.log to know what the serialPort npm Node module serial output is like (I've edited the file wrapper.js in the node module directory : node_modules\sds011-wrapper\wrapper.js) Here a sample view of wrapper.js where I've put my console.log:
now the output :
you can see that the BaudRate is default to 9600 (wrapper.js), and I've set the same value when I use the sensor connected to Espruino Pico, here is my code :
with result like :
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-22 by Robin Ahhh, much better. What version of Espruino is running? Now the fun begins!! Everything appears okay at first glance. Have you confirmed Baud Rate in WebIDE? (guess yes) I had something like this a while back, and I was never entirely sure if the IDE needed the same Baud Rate setting. Is it possible that Rx is not actually connected to Tx, and Tx -> Rx? e.g. pins reversed - worth a shot flipping them Has a loopback test connecting the Pico Tx -> Rx been tried, in order to convince yourself the Pico works on the selected Serial Port? Has a different Serial port been attempted? or, Software Serial? Are those data packets returned only during the 'data' event? e.g. or is there other interval timing code that should be present? Other things to try as was discovered (ref GND), different device though: > http://forum.espruino.com/conversations/334718/ |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-22 by AkosLukacs Long shot (sorry, got to put the kids to sleep, so this is just my first guess): I think it's binary, that's why you see garbage characters. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-23 by maze1980 You should replace
with
to see numbers instead of text. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-23 by Robin Sun 2019.06.23 Has Is there a clock line being used, and is it setup in both hardware and softwre correctly? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by larry first, thank you all for your post!
"VERSION": "2v03",
Pico is connected by USB to my PC, and the SDS011 (5V needed) sensor is powered by an Breadboard Power Supply Module 3.3V 5V. @AkosLukacs below, sample output of
well, It's maybe a correct output, comparing the output serial from the Node.js script when the sds011 module is running, I've got
converting to decimal is
Reading the SDS011 doc, I should always get aa c0 (170 192 ) starting byte ... and ending with ab (171). I have to go to work now (already late) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by AkosLukacs
That (not connecting the two GNDs) is possibly the source of the "random" characters you see. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by @gfwilliams Sorry I'm a bit late to this - not connecting GND is likely to be a big cause of the mismatch of data you're getting. Connecting GND together on all devices won't cause you any issues at all (in fact not connecting GND is far more likely to break things as you can end up really stressing the IO pins). The Pico has a 3.3v output which should be capable of about 200mA sustained, 400mA peak - however I'd only use that for stuff that needs regulated 3.3v (eg. not a power supply). The Pico also has a VBAT pin which provides somewhere in the region of 4.5v when from USB or battery voltage when powered from battery, so I would use that: https://www.espruino.com/Pico#pinout There's even a self-resetting fuse in there so if you draw too much power (>500mA sustained) from USB it'll just temporarily cut out without breaking anything. It's entirely likely that the sensor will function perfectly fine from 4.5v without the boost converter - but if you're planning on switching to LiPo power and some point then you'd probably want the converter. When on LiPo you can just connect the LiPo power to BAT_IN and the Pico will automatically power from USB when USB is connected, or LiPo when USB isn't. Just a note: The baud rate specified in the Web IDE will have no effect for you on the Pico, since the Pico is connected by USB. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by larry
I'll try this tonight !
didn't know that, it's cool |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by maze1980 Does the Pico request 500mA from the USB bus when connected to a PC? And what does it do when it's only allowed to use 100mA? Anyway, assuming your USB port can provide 500mA that's enough for the Pico (32mA) and the sensor (70mA +/-10mA), no need for an external power supply. When using multiple power supplies you MUST connect the ground of all power supplies together. Otherwise there might be a measurable voltage difference between the different grounds, e.g. due to power supply design or due to electrostatic charge. -> Remove all data cables before connecting grounds together, otherwise you might damage your chips. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by Robin Mon 2019.06.24 @maze1980, as you have explained the ground issue correctly, am a bit puzzled by your first sentence then, even with the ground issue knowledge.
Electronic devices connected to a supply (the load) will pull what ever is needed to meet the load demand. If the Pico is at idle, then it will only For the (100ma) situation, if there are no other parts connected to the regulator downstream, then the load draw as explained above applies. If say ten LEDs attempting to draw more than the (100ma) supplied, then those and the Pico will be limited to the (100ma) available, and the LEDs will be slightly dimmer and possibly the Pico may not function at all. A reason to always focus on the supply first, then design the circuit. Remember this is Ohm Law: E = I * R or I = E / R or R = E / I
For USB ports, the slightly older USB2 can supply (500ma) as is indicated, while USB3 can supply up to (900ma) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by maze1980 @robin: USB devices must be in low-power mode (max. 100 mA) initially. They can negotiate high-power mode (max. 500 mA for USB2.0), and only then they are allowed to use more power. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by larry Powering SDS0111 module to Pico VBAT & GND give correct buffer serial sequence, how cool is that ? hum ? thank's bro, Espruino rock's, yeah! got an PM2.5 sensor ready to go, I will be able to leave with and be disgusted to be completely in a cloud of pollution nearly all day long, cool!
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-24 by Robin @maze1980, thank you for reminding us on that limitation.
IMO I doubt it, unless one carelessly shorts the data pins or V+ I have a three year old laptop with both USB2 and USB3 ports. It has always blindly allowed me to pull at least 500ma from the USB2 ports. Probably as it actually read this:
> https://www.electronicdesign.com/interconnects/introduction-usb-power-delivery > https://electronics.stackexchange.com/questions/5498/how-to-get-more-than-100ma-from-a-usb-port The process of enumeration: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-25 by @gfwilliams @larry great! Glad you got it sorted! @robin @maze1980 if you want to discuss the USB power delivery maybe we could do so in a new thread rather than sidetrack @larry's. But to confirm: Espruino does not request additional power from USB. I would be utterly staggered if any USB port could be damaged by drawing 500mA out of the power lines. Even if Espruino did request additional power it would be pointless because you're only supposed to draw the power after requesting it and there is no 'switched 5v' output that could be used. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-25 by maze1980 Regarding the USB power it's not worth implementing anything: I don't think any developer would ever check even if it was implemented. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-06-26 by larry @maze1980 I'm on the way for it, I'll post a module to easily use the sensor here :) hope very soon ! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-01 by larry Here is the module for the SDS011, according to the manual to check the checksum and get proper value for PM2.5 and PM10.
Entry point :
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-01 by AkosLukacs Nice! If you get rid of Just replace this
with
I think I got the indexes right, tho just tested it in browser console with the sample in comments. :) If you use
with something like
And probably you have to change the buffer index checks to prevent overflow, if the data is not correct. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-01 by larry
yeah, it's a shame! nooo, it's the first time I try to interpret raw output data from sensor, so your comment helps me better understand on what's going on. din't know about E.sum, i found more informations from the waveform exemple code very interresting, like :
I correct my duties at home, and I come back with a better copy, lol! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-01 by maze1980
I'd call this highly optimistic, you would simply write
If you're out of sync for any reason there would be no more measurements, in both code variants. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-02 by larry I did something more concise, following your advice:
I 've started to build a closure with an soap plastic box, with inside the dust sensor, an ESP8266 or Espruino Pico and a small 128*64 Oled screen. I would take data measurements while walking in Paris. I am curious about the results especially at the level of the big automobile hub, and close to the ring road. I'll post the full project in the "Project" section of the forum if I do not encounter new problems ! (I have never used the Oled screen) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-02 by AkosLukacs I'm working on something similar. OLED displays with Espruino are pretty easy, if you wire up it properly :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-02 by larry
yes, I've seen this! maybe I'll build their module and contribute to! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-07-02 by @MaBecker Just created an account, will try to get this working with Espruino firmware |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-06-22 by larry
I bought a fine particle sensor, the sds011. This sensor has a USB socket that allows me to test it super fast with a Node.js script (SDS011-Wrapper) it works very well.
Now I want to make a "more" portable solution, by connecting the sensor with Espruino Pico.
This sensor is connected in Serial.
During my tests using a Node.js script, I have exactly an hex bytes buffer output that corresponds to the documentation, like :
For exemple, to get the PM2.5 value :
PM2.5 value: PM2.5 (μg /m3) = ((PM2.5 High byte *256) + PM2.5 low byte)/10
Where PM2.5 High byte = 05(Hex) = 5(decimal)
and PM2.5 low byte = 1b(Hex) = 27(decimal)
(reading de doc), after converting the Hex data to Decimal
Now, connecting Pico serial to this sensor and console.log the serial output give me weird result (exotic characters, like ÿ ô , etc ...). I know I missing something, I know I should convert the sensor serial output to decimal data but I don't know where to start?, well in fact I don't know what is the type of data the sensor give me? an array of Hex?, decimal ASCII values ?
Will apreciate your help if someone have already use this little cool device !
larry
Beta Was this translation helpful? Give feedback.
All reactions