meeki007 / node-red-contrib-ads1x15_i2c

A node-red node providing access to a ADS1x15 I2C analog to digital converter
Other
1 stars 0 forks source link

Why you created so complicated payload object? #2

Open Barabba11 opened 3 years ago

Barabba11 commented 3 years ago

Hi, I appreciate a lot your node, works good, but I don't know how I can exctract just tne measure I need, millivolts (you created the proprety "miliVolts") of each channel. I'm not an expert of javascript and whe following code doesn't work: var ADC0 = msg.payload./dev/i2c-1.ads1115.0x4A.singleEnded.channel_0.miliVolts; You would better avoid special chars like "/" in objects, and consider to create just msg.payload.channel_0.millivolts, leave to other objects the other not important informations.

I suppose that now I need to convert the object ito a string and search for text, then point on the value. This is absurd

meeki007 commented 3 years ago

I will create a simplified button for objects this weekend. That way it will only spit out channel objects. I created the complicated object for database and mqtt sorting. I run multiple ADC's on different addresses that get combined into one payload so I wanted a object that told me where it came from ......sorry m8

Barabba11 commented 3 years ago

Thank you, I couldn't figure out how to get data from that object, somebody helped me. Yes it's a good idea, sempllofy for other people. Usually we just need ADC values

Lyubomir-Todorov commented 2 years ago

For anyone still running into this issue, the properties need to be accessed using bracket notation. Accessing the values should look like the following: msg.payload["/dev/i2c-1"].ads1115["0x48"].singleEnded.channel_0.Volts