I am considering using this PH Module from Atlas to sense Ph levels. In the second illustration they have connected the module to the analog pins of the arduino. Would the same apply for a Photon?
They also have an EC module that i want to use but will try the Ph first to see if it all works for my purpose.
@Ali, that module uses I2C so it would be connected to pins D0/D1 of the Photon. The Arduino uses different pins for I2C which are also used as Analog inputs.
ok so at the moment. I have 4 AM2302 from D0 to D3. D4 will give power to them all. RX and TX are connected to the nextion. I will need 4 more digital pins to connect botht eh EC and the TDS sensors. Can analogs be converted into Digital IO’s?
As @peekay123 said, if you want to use that Ph module, you'd need to free D0/D1 for it, but you can use A pins just the same as digital pins, but I'd not use A3 and A6/DAC if I don't need to, since these are the only non-5V-tolerant pins.
Just to stay clear of accidental feeding 5V to those pins.
I2C is a bus meant to communicate with multiple devices via these two pins.
The easiest is if your sensors allow to set individual bus addresses, but if not, you might still be able to have multiple sensors of the same kind if you can power them mutually exclusive.
Im trying to set up the Photon to receive serial data from the Nextion. There is a function called sendme that sends 5 bytes of data. I can see that in the emulator but how do i receive that on the Photon. I tried doing
if (Serial.available() > 0)
{
char1 = Serial.read();
}
but i do not receive anything from that. Anyone have any experience with this?
If you want to do that yourself, you’d use a loop or Serial.readBytesUntil() to catch all bytes in one go.
But there is an ITEADLIB_Nextion library I ported that would do that for you.
There’s a function to send the command and its return value would be the Nextion response to that command.
I am using your library. i have thsp and thup on every page on the touchscreen. Now once the page times out on touch press gets back to the screen it originally was. What I want is for it to go to the first page which has a passcode. What I thought was to use sendxy=1 from the touchscreen and then some way to listen for this on the photon.
Actually, I'd do that in the Nextion code on the display.
In fact I would do as much as possible on the display and only what's absolutely required in the MCU.
What would you want to get notified about this way?
I'd rather push that info from the display and only "subscribe" to that event via a dedicated callback - as you would do for any touch interaction with the display.
This is called by a timer. But that is not the best way to do it. In the editor there are commands for making the screen go to sleep and wake up on touch. But on wake up it goes to the page it went to sleep on. What i am doing right now is forcing the page to change to the first page based on the timer and then the function for sleep kicks in right after on the now current page. “thsp” sets a timer from last touch but the timer i have set up is active from the moment the page is loaded. What i need is the page to time out from last touch and on wake up go to another page.
I agree with putting most of the program on the touch screen itself and believe me that is what i am trying to do. The only stuff that i want to set up via MCU are the interactive texts and pictures.
In Nextion Editor you can place a Timer component and a Variable component, increment the variable via a timer script, reset the variables via any other components on-touch/on-release script and fire a page select statement in the timer script when the variable reaches a certain value.
No action required by the MCU at all.
But if you want to notify the MCU you can also use printh or several other messages from the timer script to trigger a particular callback.
I’ve no Nextion display with me at the moment, so I can’t provide you a working solution, but I might be able to send you one next week.
What type display have you got?
I am using a NX4827T043_011. To increase the timer i would have to setup the variable to increase on touch of every component on screen. Worst part is that the timer has a limit to 65000 ms and i would actually want time out to be over 2 mins. As always i appreciate your advice greatly.
there is a timer attached to the above function in the MCU. So the page will goto splash regardless of whether the user touched the screen or not which is not a best practice thing. I am following what you are suggesting though now.
Timer starts the moment page loaded
button press resets the timer
as long as something is pressed or touched timer keeps updating.
Only issue is i would have to put that in all the components now. I have about 24 screens as off now. That is why was looking for a shorter way to do this.