Hello
brand new .. take it easy on me.
I want to read digital inputs over wifi on myUNO REV 4 wifi , and I have not been able to find any examples or tutorials. I have theSImpleWebServer example, which works to turn the onboard LED on and off
and I have DigitalInputPullup, which reads the status of input pin 2
both of them work...
I would like to read the status of input pins over wifi... can someone direct me to some tutorials or examples... I haven't been able to find any
thank you
I think you have the wrong concept of what you want. You must have some computer or micro-controller to READ the input pins and send that data over wifi to your UNO REV4.
Unfortunately i see what i wrote is exactly what you read
I want to read the inputs on my UNOrev4 wifi with my laptop over wifi
I will have 5v on or off connected to digital inputs on my arduino and i want to be able to “read” them on my windows 10 laptop in some usable manner. Using wireless wifi…using them in a visual basic.net program. Hopefully
Exactly the same situation. If you want a program in your PC to read a value, you must have a PC program to tell your UNO to read and then send that value to your PC. There is no magic.
Take a look at telemetrix. It handles all serial communications, and once you set a digital pin as an input, all data changes on that pin are automatically reported.
Telemetrix provides a Python API.
Here is a sample:
import sys
import time
from telemetrix import telemetrix
"""
Monitor a digital input pin
"""
"""
Setup a pin for digital input and monitor its changes
"""
# Set up a pin for analog input and monitor its changes
DIGITAL_PIN = 12 # arduino pin number
# Callback data indices
CB_PIN_MODE = 0
CB_PIN = 1
CB_VALUE = 2
CB_TIME = 3
def the_callback(data):
"""
A callback function to report data changes.
This will print the pin number, its reported value and
the date and time when the change occurred
:param data: [pin, current reported value, pin_mode, timestamp]
"""
date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data[CB_TIME]))
print(f'Pin Mode: {data[CB_PIN_MODE]} Pin: {data[CB_PIN]} Value: {data[CB_VALUE]} Time Stamp: {date}')
def digital_in(my_board, pin):
"""
This function establishes the pin as a
digital input. Any changes on this pin will
be reported through the call back function.
:param my_board: a telemetrix instance
:param pin: Arduino pin number
"""
# set the pin mode
my_board.set_pin_mode_digital_input(pin, the_callback)
print('Enter Control-C to quit.')
try:
while True:
time.sleep(.0001)
except KeyboardInterrupt:
board.shutdown()
sys.exit(0)
board = telemetrix.Telemetrix()
try:
digital_in(board, DIGITAL_PIN)
except KeyboardInterrupt:
board.shutdown()
sys.exit(0)
Yeah im trying to find out how to do that.
Do you know how?
Thank you Mr Y
Is this wifi?
I don’t want to use serial
I have a labjack and it works well but im trying to lose the wire between the microcontroller and the computer
No, never done it on a PC or an Arduino. But there are lots of threads on the forum relating to your project.
You are going to need some kind of protocol like mqtt, http, udp, sockets etc.... Then write a program on the pc to talk to your board. Your board will have a program that talks to your pc over the protocol. Think of wifi as just the carrier frequency.
Or you can use the cloud services where there are envirnoments setup to make it easy to do what you want, like arduino cloud for instance or the things network.
Yes… I would like to know specifically how to do that… I don’t expect anyone to answer this completely… I’m new to Arduino but I have been messing with this sort of thing for forty years… I don’t know how to “do” wifi… I have a tiny amount of experience with C+ and HTML I just don’t know how to do much with this specific product…
I see all the you tube videos with the cell phone and turning the light on and off and I have downloaded and had success with the examples of reading the inputs serially and turning the LED on and off from the web browser over wifi , but I haven’t seen anything on reading the inputs over wifi... and that's what brought me to this arduino in the first place... trying to eliminate the USB or the serial cord when reading inputs
I have been trying to “integrate” the reading inputs serially (DigitalInputPullup) with the turning the LED on and off over wifi (SImpleWebServer), but so far it is a dud… I have no experience with that sort of thing (the web server ), and I had hoped to see a more complete example or tutorial. If anyone knows of something , please let me know.
I guess back to the ol’ change something and try to compile it. I actually have something that compiles but it doesn’t do anything…. Which is another problem … how to debug …. Has a debug button that doesn’t seem to work… although I will say that the error messages seem to be pretty specific.
Thanks to those who replied.
Hi @realolman. There is an example sketch named "WiFiWebServer" that comes with the "WiFiS3" library of the UNO R4 WiFi board. This sketch does almost exactly what you want, except that it provides the analog readings from the pins on the board instead of the digital readings. But it would be trivial to change it to use digitalRead
instead of analogRead
, and so I think this example will serve as a good reference for your project.
You can open it by selecting File > Examples > WiFiS3 > WiFiWebServer from the Arduino IDE menus.
You are poisoning your search by being too specific.
You already know how to write the Arduino sketch code to read the digital inputs. So you only need to learn how to write the sketch code to send arbitrary data from the board over the network. There is absolutely no need to find a reference that tells you how to send digital readings specifically.
If you were trying to learn how to juggle, and you happened to want to juggle Penn brand tennis balls, would you be better off with a search for "how to juggle penn brand tennis balls", or with a search for "how to juggle"?
This appears to me to be a great big BINGO!
Thank you very much
It was the very last thing on the list of examples and even now I had a hard time finding it...it was hidden by my taskbar.... That's a poor excuse I know ...and I thank you very much, ptillisch .. that is exactly the kind of help I had hoped to find here.
back to the basement
I am unsure what you are trying to do and how things are interfacing with each other. What has thrown me off is using labjack. I don't think Telemetrix will help you there.
However, if you wish to play with the Uno R4 WiFI, there is a version of Telemetrix specifically for that board.
Thank everyone who replied...MrY I will look into telemetrix
I was just trying to give you an example of what I was trying to do... the labjack has a bunch of inputs and outputs but it needs to be connected to a computer by a usb cord at all times.
I wanted to perform a similar function with the UNOR4wifi without the usb cord and with some stand alone computing by the UNO... thank you very much for your reply... perhaps with telemetrix, I won't have to re-invent the wheel
ptillisch: I have the analog signals on the UNO appearing on a web browser in visual basic .net... I will have to figure out how to get them from there to some usable form in a VB.net program.
That oughta keep me busy for a while.
Thank you very much ... that was exactly the push I was looking for
You are welcome. I'm glad if I was able to be of assistance.
Regards, Per