Send email from discrete input change

Hi, how do I code the Nano 33 IoT to send emails triggered by a change in discrete input?

Welcome to the forum

Where are you stuck ?

Start by detecting the change of state of an input. The StateChangeDetection example in the IDE will show you how to do this

Then you can move on to sending an email as a result of the state change

Ok thanks, I am seeking information on how to tie all of these pieces together. Is there a library example that can be pointed to where I can affect changes simply. Ex: If state change, then run send email... ?

It is extremely unlikely that such a library exists

Have you actually got the pieces working that you want to tie together ?

Can you detect a state change on an input ?
Can you send an email ?

If not, then get each of them working individually first and then tying them together will be easy

I have neither working within the IDE software, though can detect the sensor change of state with a volt meter. Can you advise how to get each of these parts going in IDE software?

Start with the state change detection

See the StateChangeDetection example in the IDE

Sending the email is not difficult but with your level of knowledge then getting it right is not going to be easy

I don't want to know what your email address is but is it a gmail address ?

for send or receive?

You will need an address to send from and one to send to but they could be the same

it's gmail, is what I set up to send from.

I can help you with that as i have it working myself using a Nano 33 IOT but there are some hoops to jump through with Gmail to allow it to work

First, get the state change detection working such that when a state change occurs a function is called to print a message then we can move on to email

OK thanks. I am tied up as the sensor I plan to use takes 5V power, so I need to solder the contacts under the board to bypass 3.3V out. As a result, state change detection, will have to be on hold, until I can get this soldered at the lab, next week. Further, I was thinking button would be a more apt sketch to run, as it's similar to state change, I think ultimately the output will be dependent on the sensor "button" here.

The 2 examples do different things
The Button example shows how to do something when the button is pressed

The StateChangeDetection example shows how to do something when the button becomes pressed

If you use the Button example to send an email then it would repeatedly send emails whilst the button is pressed. That is OK if that is what you want, but only you can know

Ultimately I need to send one email when there's a change of state on a sensor and only when it's high. Is button not the best program to achieve this?

No. Look at it carefully. Each time that the input is found to be HIGH it turns on the LED. Imagine that it sent an email every time the input was found to be HIGH, bearing in mind that loop() repeats the code many thousands of times per second

I appreciate the help. Deciphering the code is a challenge as I'm new to the whole thing.
I'll have to look at the changeofstate program, and manipulate it to turn on the LED (send an email) only once when it goes high.

Make sure that you understand the implications of this

If the sensor is a 5V device and does not take much current then it is OK to power it from the Arduino.

What is not OK is for the sensor to send a 5V signal to any of the IO pins of the Nano 33 IOT, as the chip could be damaged by the excess voltage applied to it. Unless, of course, you intend to use a voltage level shifter between the sensor and Arduino

Soldering the jumper on the board to enable the 5V output pin does not turn the Nano 33 IOT into a 5V tolerant device

thanks mate, I definitely thought it could take 5V on the digital inputs!

Whoops, but al least disaster has been averted

From https://docs.arduino.cc/hardware/nano-33-iot

Please read: operating voltage

The microcontroller on the Arduino Nano 33 IoT runs at 3.3V, which means that you must never apply more than 3.3V to its Digital and Analog pins. Care must be taken when connecting sensors and actuators to assure that this limit of 3.3V is never exceeded. Connecting higher voltage signals, like the 5V commonly used with the other Arduino boards, will damage the Arduino Nano 33 IoT.

I have been able to successfully recognize a change of input state to trigger an LED with the NANO 33 IoT. I am wondering: how to configure an output in place of the LED that is either: 1) an email or a text message from the Arduino app. I'm not sure which might be easier to configure. Any insight? Thanks in advance,

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.