rednet.open("top")
isGenerating = false
p = peripheral.wrap("back")

while true do
    battery = math.floor((p.getEnergy() / p.getMaxEnergy() * 1000))/10
    if isGenerating and battery >= 90 then
        isGenerating = false
    elseif not isGenerating and battery <= 80 then
        isGenerating = true
    end
    rednet.send(1, isGenerating)
    rednet.send(2, {battery=battery, isGenerating=isGenerating})
    sleep(1)
end
