Forum

Raspberry Pi Zero W...
 
Notifications
Clear all

Raspberry Pi Zero W controlled Server power monitor with TXT message alerting.

3 Posts
1 Users
0 Likes
8,680 Views
CrackedConsole
(@crackedconsole)
Member Admin
Joined: 5 years ago
Posts: 368
Topic starter  

I've started working on a small side project for work, a power monitor for a offsite location and or server site location.

The idea of it is, it will run a Raspberry Pi Zero W with a battery backup, charging module, GSM module and utilize the on board GPIO pins for triggering.

 

Basically, we hook a standard 5v wall plug into the box that is then split into 2 legs.

1 goes to the battery charger/battery and powers the Raspberry Pi

1 goes to a voltage regulator (and capacitors) to drop the voltage down to 3.3v, this is now safe and low enough to be read as in input on the raspberry pi GPIO pins.

The system has power, the pi runs off the 1st 5v leg thats also maintaining the battery, and providing 3.3v via leg 2. This tells the Pi that its getting power from the wallwart.

Power drops, the charge circuit swaps to using battery, leg 2 is no longer live and pulls the Pin on the Pi GPIO to LOW thus executing a script on the Pi OS to send a text msg that it is down.

Theres a couple small wiring diagram issues, ie power out from the charging IC goes to the bottom of the pi for power in, not to the GPIO pins 5v power. I still have to test this and make sure a diode isn't needed on the power in to assure theres no reverse voltage back fed from the 5v Input that ends up pulling the GPIO pin back to HIGH when running on battery

 

And a generic MS Paint early draft, this wiring is till not tested (same as above), as I plan on building it this weekend.
The GPIO wiring for sure is not correct in this image, and do not use it as golden as it was an initial quick brainstorm

Installing Python Dev tools

sudo apt-get update
sudo apt-get install python-dev python-pip
sudo pip install --upgrade distribute
sudo pip install ipython

Installing Raspberry Pi GPIO and serial

sudo pip install --upgrade RPi.GPIO
sudo apt-get install python-serial

 

Python Code for sending a TXT message

import serial
import RPi.GPIO as GPIO
import os, time

GPIO.setmode(GPIO.BOARD)

# Enable Serial Communication
port = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=1)

# Transmitting AT Commands to the Modem
# '\r\n' indicates the Enter key

port.write('AT'+'\r\n')
rcv = port.read(10)
print rcv
time.sleep(1)

port.write('ATE0'+'\r\n') # Disable the Echo
rcv = port.read(10)
print rcv
time.sleep(1)

port.write('AT+CMGF=1'+'\r\n') # Select Message format as Text mode
rcv = port.read(10)
print rcv
time.sleep(1)

port.write('AT+CNMI=2,1,0,0,0'+'\r\n') # New SMS Message Indications
rcv = port.read(10)
print rcv
time.sleep(1)

# Sending a message to a particular Number

port.write('AT+CMGS="+6xxxxxxxxx68"'+'\r\n')
rcv = port.read(10)
print rcv
time.sleep(1)

port.write('Hello User'+'\r\n') # Message
rcv = port.read(10)
print rcv

port.write("\x1A") # Enable to send SMS
for i in range(10):
rcv = port.read(10)
print rcv

 


   
Quote
CrackedConsole
(@crackedconsole)
Member Admin
Joined: 5 years ago
Posts: 368
Topic starter  

CME Error codes

Error
Description
CME ERROR: 0
Phone failure
CME ERROR: 1
No connection to phone
CME ERROR: 2
Phone adapter link reserved
CME ERROR: 3
Operation not allowed
CME ERROR: 4
Operation not supported
CME ERROR: 5
PH_SIM PIN required
CME ERROR: 6
PH_FSIM PIN required
CME ERROR: 7
PH_FSIM PUK required
CME ERROR: 10
SIM not inserted
CME ERROR: 11
SIM PIN required
CME ERROR: 12
SIM PUK required
CME ERROR: 13
SIM failure
CME ERROR: 14
SIM busy
CME ERROR: 15
SIM wrong
CME ERROR: 16
Incorrect password
CME ERROR: 17
SIM PIN2 required
CME ERROR: 18
SIM PUK2 required
CME ERROR: 20
Memory full
CME ERROR: 21
Invalid index
CME ERROR: 22
Not found
CME ERROR: 23
Memory failure
CME ERROR: 24
Text string too long
CME ERROR: 25
Invalid characters in text string
CME ERROR: 26
Dial string too long
CME ERROR: 27
Invalid characters in dial string
CME ERROR: 30
No network service
CME ERROR: 31
Network timeout
CME ERROR: 32
Network not allowed, emergency calls only
CME ERROR: 40
Network personalization PIN required
CME ERROR: 41
Network personalization PUK required
CME ERROR: 42
Network subset personalization PIN required
CME ERROR: 43
Network subset personalization PUK required
CME ERROR: 44
Service provider personalization PIN required
CME ERROR: 45
Service provider personalization PUK required
CME ERROR: 46
Corporate personalization PIN required
CME ERROR: 47
Corporate personalization PUK required
CME ERROR: 48
PH-SIM PUK required
CME ERROR: 100
Unknown error
CME ERROR: 103
Illegal MS
CME ERROR: 106
Illegal ME
CME ERROR: 107
GPRS services not allowed
CME ERROR: 111
PLMN not allowed
CME ERROR: 112
Location area not allowed
CME ERROR: 113
Roaming not allowed in this location area
CME ERROR: 126
Operation temporary not allowed
CME ERROR: 132
Service operation not supported
CME ERROR: 133
Requested service option not subscribed
CME ERROR: 134
Service option temporary out of order
CME ERROR: 148
Unspecified GPRS error
CME ERROR: 149
PDP authentication failure
CME ERROR: 150
Invalid mobile class
CME ERROR: 256
Operation temporarily not allowed
CME ERROR: 257
Call barred
CME ERROR: 258
Phone is busy
CME ERROR: 259
User abort
CME ERROR: 260
Invalid dial string
CME ERROR: 261
SS not executed
CME ERROR: 262
SIM Blocked
CME ERROR: 263
Invalid block
CME ERROR: 527
Please wait, and retry your selection later (Specific Modem Sierra)
CME ERROR: 528
Location update failure – emergency calls only (Specific Modem Sierra)
CME ERROR: 529
Selection failure – emergency calls only (Specific Modem Sierra)
CME ERROR: 772
SIM powered down

   
ReplyQuote
CrackedConsole
(@crackedconsole)
Member Admin
Joined: 5 years ago
Posts: 368
Topic starter  

Well, after much dismay, I could not get the SIM800L connected to a network... It appears this device I bought on a whim wasn't supported on today's network as it only uses 2G.

SIM5320A on eBay

and an Antenna

3G Antenna

The new 3G SIM module should get here in the next Month... sigh, but we shall see.


   
ReplyQuote
Share: