0

Read and write values to and from the same feed/slider
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Read and write values to and from the same feed/slider

by jdnicholas on Wed Dec 09, 2020 7:05 pm

I have a Neopixel ring connected to an ESP8266 board, where I have used potentiometers to set the RGBW values for the pixels to control the colour that is displayed, coded using the Arduino IDE. With a second, identical Neopixel/ESP8266 device, I was hoping to be able to use the Adafruit IO to take the RGBW values read from either of the devices, and then synchronise the other device to update the colour displayed. If the values could additionally be set for both devices by setting the values with sliders on a dashboard that would also be great.

Is this possible to achieve with the Adafruit IO? I have some experience with Arduino coding etc, but would still very much classify myself as a beginner, and have not used the Adafruit IO before. I have read through the Basics guides though, and got the Adafruitio_14_neopixel example working fine, where the colour of the rings is set using the colour picker on the Adafruit IO dashboard. I've also had a look through some of the other examples and guides and haven't managed to find anything that exactly fits what I'm looking for, but if I've missed anything obvious please let me know.

Happy to post code and/or diagrams if needed, but thought I'd ask the question more generally first.

Many thanks in advance!

jdnicholas
 
Posts: 3
Joined: Sat Dec 05, 2020 4:19 pm

Re: Read and write values to and from the same feed/slider

by brubell on Thu Dec 10, 2020 10:32 am

Not sure I'm understanding - you want to add 3x sliders, one for R, one for G, one for B? and display it on the device?

brubell
 
Posts: 1417
Joined: Fri Jul 17, 2015 10:33 pm

Re: Read and write values to and from the same feed/slider

by jdnicholas on Thu Dec 10, 2020 10:56 am

Essentially, yes.

Currently, I control the overall Neopixel colour using a potentiometer to set the R value, a different potentiometer for the G value and a third for the B value.

The two devices are independent, but what I would like is to be able to do, for example, turn the potentiometers on Device 1 to e.g. 255,0,0 to get Red on the Neopixel, and through the Adafruit IO, set the R, G and B feeds, (and hence also sliders) to 255, 0 and 0 respectively, and pass this onto Device 2.

Then, if Device 2 updated the colours to e.g. 255,0,255 for purple, this would update the feeds and set colour to purple on Device 1 also.

So as I understand it, I would have to be both reading and writing values to the same feed to achieve this? The device that uses the potentiometers would write to the feed, and the other would read from it. Since I would like both devices to act as a leader or a follower in setting the colour, I guess this is where it becomes more complicated than just having different code for each device to either read or write the R, G and B feed values.

I hope that’s cleared things up, but if not please do let me know and I can try and explain better!

jdnicholas
 
Posts: 3
Joined: Sat Dec 05, 2020 4:19 pm

Re: Read and write values to and from the same feed/slider

by brubell on Fri Dec 11, 2020 10:28 am

So as I understand it, I would have to be both reading and writing values to the same feed to achieve this?

Both devices would need to be subscribed to the same feed(s).

The either/or nature of this problem is a bit difficult since you can not filter out feeds by which client/device wrote to it....

I suggest making one feed which each device receives from and one feed for writing:
device1/tx
device1/tx
device2/tx
device2/rx

Device 1 would write to device 2's tx feed. and subscribe to device 2's rx feed. Same pattern for device 2's setup. That way, there's no possibility of device2 obtaining a message it just wrote to a feed.

Does this implementation make sense?

brubell
 
Posts: 1417
Joined: Fri Jul 17, 2015 10:33 pm

Re: Read and write values to and from the same feed/slider

by jdnicholas on Sat Dec 12, 2020 11:47 am

brubell wrote:Does this implementation make sense?


Yes, I think that sounds like the easiest way to do things then - will give it a go and see if I am successful. Thanks!

jdnicholas
 
Posts: 3
Joined: Sat Dec 05, 2020 4:19 pm

Please be positive and constructive with your questions and comments.