Pages: [1]   Go Down
Author Topic: Simple flour grinder monitor (wireless!)  (Read 1189 times)
0 Members and 1 Guest are viewing this topic.
Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 223
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We make our own bread here at my house, including grinding flour.
This makes for excellent bread, but the flour grinder needs to be checked often while it's grinding.  If it runs out of grain the stone starts working it's way loose and eventually falls into the flour and causes issues.

Enter the Bobnova Grinder Monitoring System.  I built it this afternoon half for usefulness and half because I had an idea and I enjoy making things.

The grinder end of things is a RBBB with a RF12B radio and a basic light sensor that is buried in the grain hopper.
When the grain gets down to ~2 minutes left, the light sensor surfaces and detects light.
It checks the light level every 200ms or so, and broadcasts that out into the world.
Eventually it'll be able to turn the grinder off, as well as monitoring the grinder RPM in case the belt starts slipping.  Right now, it just blasts the light level detected out into the world.
On the receiving end is another RBBB+RF12B combo, this one with a green LED and a very bright red LED (ripped it out of an optical mouse, nice LED!).

The green LED flashes every time a valid CRC-OK packet shows up, so you know that the two are still in communication.
Once the light level goes above a level I would describe as "very dim", the bright red LED starts flashing.  At this point the red LED continues flashing regardless of whether the light level stays bright or not.  This'll include a buzzer eventually.

The code is quite simple, the jeenode RF12 library makes the radio extremely easy to use.


Transmitter/sensor code:
Code:
#include <Ports.h>
#include <RF12.h>  //have to include Ports.h and RF12.h, RF12.h depends on Ports

struct {
  int light : 12;  //build-your-own data types make the radio *really* easy to use
  int alert : 2;
} sendData;

int light;


void setup(){
//  Serial.begin(57600);
  byte test = rf12_config();            // looks weird, but rf12_config can't be called by itself for some reason.
}

void loop(){
  light = 0;
  for(int x = 0 ; x < 10 ; x++){
    light = light + analogRead(5);   //  lots of reads with a brief delay helps a lot in getting rid of random noise
    delay(1);                                    //  like that caused by the chunky 120v 60hz motor driving the grinder
  }
  light = light / 10;
  sendData.light = light;
 
  rf12_recvDone();                                                      // recvDone keeps the radio happy, it has to be called from time to time
  if (rf12_canSend() == 1){                                          //make sure we're allowed to send, can't send without checking first.
    rf12_sendStart(0, &sendData, sizeof sendData);  //blast the data off into the world, not aimed at a given radio nor asking for ACK
  }
  delay(200);
}


Receiver/alarm unit code:
Code:
#include <Ports.h>
#include <RF12.h>


typedef struct {
  int light : 12;
  int alert : 2;
} Payload;
Payload receivedData;

unsigned long lastReceived;
boolean ZOMG = false;


void setup(){
  Serial.begin(57600);
  byte initRF12 = rf12_config();
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
}


void loop(){
  if (rf12_recvDone() && rf12_crc == 0 && rf12_len == sizeof (Payload)){
    receivedData = *(Payload*) rf12_data;
    Serial.println(receivedData.light);
    lastReceived = millis();
    if (receivedData.light > 150){
      ZOMG = true;
    }
    digitalWrite(7,HIGH);
    delay(50);
    digitalWrite(7,LOW);
  }
  delay(50);
  if (ZOMG){
    digitalWrite(7,LOW);
    digitalWrite(8,HIGH);
    delay(100);
    digitalWrite(8,LOW);
  }
}




Just tested it out, and it works quite nicely.
Radios are great fun, and these RF12B modules only cost $7ish at moderndevice.  Sparkfun has 'em as well.
I highly recommend them.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

nice done ...i will use your code,
i will modify your code ..... to send 6 analog inputs .....to a receiver  with 6 led's
thank you again!!!
Logged

Pages: [1]   Go Up
Jump to: