Tracking wheter the machine is running or not..

Hi.

I Think here are many peoples who could help me with one project im planning to do or at least dream of doing.

I would like to make a system that could get info on a certain automation machine wheter is it running or not. I'm planning to use vibration switch for arduino. When a certain vibration is detected it gives gives 1. I don't need analog data but only 1 or 0.

Then i would like to have a screen and a small keyboard that you could select a user by number. That userdata and the data of the vibration switch would then be passed to a rasperry for example. With wifi or bluetooth.. Or can you send a data from arduino straight to a cloud server? I would like to gather this info in a PowerBi to see how long the machine has runned. So the main purpose is to see how long has the machine been on.

Any advices on how to get started? Any help would be appreciated.

Thnak you very much in advance.

mista:
I would like to make a system that could get info on a certain automation machine wheter is it running or not. I'm planning to use vibration switch for arduino. When a certain vibration is detected it gives gives 1.

Start there: forget the RPi and the cloud and stuff. See if you can reliably get a sensor to tell you if the machine's running.

Then use state change detect to look for the input to go from 0 to 1, start the clock. When it goes 1 to 0, stop the clock and calculate how long that run was. If you need to know individual run lengths, save them in an array, else just keep a running total.

Every now and then report total run length (and or individual run lengths) as a % of total time since the Arduino powered up or you last reported.

Then once that all works, and you're satisfied the numbers actually give you some meaningful useful management info, think of uploading.

ps you can check the logic with just a normal switch of course. Easy to get the code working to check your timer and storing the result, with just a normal switch.

Is there no way you could tap into the machine to take a signal to the Arduino through say an opto-isolator to capture the fact the machine's "on"?

read what an X/Y PROBLEM is

Then define your application.

equipment moving typically requires power.o
vibration can be sensed, so can power use

you can have 2 or 4 LED's, different colors, showing levels of operation.
that way you have local feedback.

you can put a numeric value if your vibration sensor value can be put into some sort of numbers.

As sayHovis said, log the values locally, even if just on the serial monitor
SD card storage is simple as is cloud storage with an ESP8266, the new NANO 33 IoT or other WiFi type boards.

once you are satisfied that you can present useful information, then moving that to the Web is not hard to do.

I recommend you get yourself one of the new Arduino Nano 33 IoT or BLE boards.

They are small and have connectivity on board. The libraries allow you to easily connect to your WiFi network or use bluetooth. WiFi is a lot easier but uses more power, so you cannot run it from battery for a long time.

First get to know the IDE and play with the simple examples reading buttons and so on. Read the getting started. This will get you a very long way.

Then move on to the connectivity examples they run out of the box with these board, just tested them myself a few days ago. You can use an MQTT protocol to send short messages over wifi to your Raspberry Pi. You can find lots of information how you can use mosquitto (MQTT broker) and other software like node-red and influxdb to get your own "cloud" like solution. It all runs localy and you do not need to share your data with anyone.

Regarding the display, make sure you get one that is supported by some library out of the box from a supplier. Check their website and read the forums, before you click buy. :slight_smile: You can connect all kinds of display but with a well supported one you are likely to have less issues.

sayHovis:
ps you can check the logic with just a normal switch of course. Easy to get the code working to check your timer and storing the result, with just a normal switch.

Is there no way you could tap into the machine to take a signal to the Arduino through say an opto-isolator to capture the fact the machine's "on"?

Thank you for many answers already.

I would like this "unit" to be separate of the machine itself and that i could do maybe smiliar units to few other machines also. We have for example Siemens plc:s on the machines but i would not like to steal any signals from those since this should be quickly and relatively easy additional system we could change from machine to another if we like. That is why i think using vibration sensor could come handy.

Power consumption is not a problem with wifi etc since i can bring external power to the system.

Well the Arduino Nano 33 IoT got you covered. There is an Accelerometer on it as well. You just need to add an additional library from Arduino to your project. There are two examples that work out of the box. Just tested it myself. Took me 2 minutes. Just tapping the bread board very gently with the finger can be detected. You can set a detection level in your software to make sure it only registeres when the vibration is strong neough.

The code looks like this.

if ( IMU.accelerationAvailable() ) {
IMU.readAcceleration(x, y, z);
...

x, y and z will give you a floating point value one for each dimension. You just compare if any of them is larger than your limit and you will know.

Mind you, an ESP8266 such as the WeMOS D1 Mini - plus an accelerometer module - is massively cheaper. :grinning:

Paul__B:
Mind you, an ESP8266 such as the WeMOS D1 Mini - plus an accelerometer module - is massively cheaper. :grinning:

Not to mention.. probably much more control over a simple 'vibration sensor' (spring & nail type of approach)....
so you can rule out 'outside' interference/vibrations as well..

ESP8266 cost roughly $3.00 USD off ebay..

Thats all you need for the MAIN board.. then of course your 'vibration sensor' of choice...
If your workplace has a local wi-fi network.. you can then connect to that and send your data to any 'end point' you want..

*ie: some server running a PHP script to collect and log your incoming 'vibration data'

Or (because you mentioned it).. you could set up the Raspberry Pi with a LAMP set up (basic web server).... and it can also have an HDMI screen to view your locally stored data.

Alot of good points there.

I guess a Arduino Nano 33 IoT is much easier for a beginner like me since it has the accelerometer built in?
I've uesd only Arduino IDE previously so everything else is unknown for me.

mista:
I guess a Arduino Nano 33 IoT is much easier for a beginner like me since it has the accelerometer built in?

No. Quite the opposite.

mista:
I've used only Arduino IDE previously so everything else is unknown for me.

You are in luck. The Arduino IDE has excellent support for the ESP8266.

Paul__B:
No. Quite the opposite.
You are in luck. The Arduino IDE has excellent support for the ESP8266.

Ok. :slight_smile:

So i need that ESP8266 card, a sensor and a power shield for ESP8266?
That's all to get started?

You will have fun with both options.

Using an Arduino Nano will support the guys who are providing the Arduino IDE. And you get a ARM Cortex-M processor instead of a Tensilica, which does not make a difference for your current project, but you can use it to learn something about one or the other.

Not sure what you mean by a "power shield".

A WeMOS D1 Mini can easily be powered by a cheap "USB phone charger". Despite a silly comment on another thread here, this is an excellent way to power and operate a device. Another interesting and ridiculously cheap alternative is one of these assemblies plugged directly into the USB charger. You could run a short lightweight flexible cable to your accelerometer board mounted on your machine as I suspect you did not actually want to mount the whole works on the machine - or did you?.

I could actually place the whole thing on the machine if it would work with wifi since the only cable that it would require is the power cable.

By power shield i ment this https://www.amazon.com/ACROBOTIC-ESP8266-7-24VDC-Raspberry-Converter/dp/B07M5N1YVZ so i could power it up by normal transformer.

I actually checked what do i already have in my boxes and i had few arduino Uno cards, esp8266 wifi module and many other small things. And i ordered that vibration sensor. Is there something i could try with this setup since i already have them?

mista:
By power shield i ment this https://www.amazon.com/ACROBOTIC-ESP8266-7-24VDC-Raspberry-Converter/dp/B07M5N1YVZ so i could power it up by normal transformer.

Cute thing, trifle expensive but just what is a "normal transformer"?

"Phone chargers" can be obtained for as little as $3 and plug directly into the WeMOS D1 Mini. (OK, I confess, I tend to pay $1 for them at "Garage sales" but they are generally about $2 or so at "Thrift shops" and $3 or so new somewhere I saw - thought it was K-mart but can't find it on line.)

I'm sorry if i wrote it badly but i ment this as a transformer for example https://www.aliexpress.com/item/32978757695.html

English is not my native language so..

Yep, it's a transformer for sure, but the "phone charger" is already perfect for the D1 Mini.

(However I must warn that these sourced from Chinese eBay vendors are suspected to have safety concerns and better to purchase from a local store who is bound by local consumer regulations.)

Is there something i could try with this setup since i already have them?

Thats the nice thing about Arduino. Start Google and Youtube, connect some wires and write some code for each of the functions you will need. Until you have your accelerometer connect a potentiometer to your A/D converter and pretend its the data from the sensor.

I found this profect and tried it with my Uno.

I get the led to blink when i snap the uno. I'm using this sensor: VMA312: VIBRATION / SHOCK SWITCH MODULE (2 pcs) – Velleman – Wholesaler and developer of electronics

It might not be sensitive enough or at least i don't know how to configure it.

Only thing i did different in my projetc i changed the digitalRead to analogRead to see more how the sensor reacts. And i also did put the serial.print to see what happens.

The code looks like this now:
#include <Arduino.h>
#include <stdio.h>

#define ON 1
#define OFF 0

int vibration_Sensor = A5;
int LED = 13;

int present_condition = 0;
int previous_condition = 0;

void setup() {
pinMode(vibration_Sensor, INPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600);
}

void led_blink(void);

void loop() {
previous_condition = present_condition;
present_condition = analogRead(A5); // Reading digital data from the A5 Pin of the Arduino.
smonitor();

if (previous_condition != present_condition)
{
led_blink();

} else {
digitalWrite(LED, OFF);
}
}

void led_blink(void) {
digitalWrite(LED, ON);
delay(250);
digitalWrite(LED, OFF);
delay(250);
digitalWrite(LED, ON);
delay(250);
digitalWrite(LED, OFF);
delay(250);
}

void smonitor (void){

Serial.print(present_condition);
Serial.print('\n');
}

For some reason when i did put that serial.print in it the led started to react less. Is it because the serialprint uses so much memory that other functions start to lag?

The sensor shows value 1024 when not active and when i shake it the value goes lower. Is there a way to set a certain trigger point for the led to go on? For example when value is < 500