Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update go-rpio to v4.6.0 to support raspi4b. #128

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions led-raspberrypi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

Light Mapper contains code to control an LED light connected to a raspberry Pi through gpio.

<img src="images/raspberry-pi.png">
<img src="images/raspberry-pi.jpg">

The following diagram has been followed to make the connection with the
LED in this case :-

<img src="images/raspberry-pi-wiring.png">

Here we are using a push button switch to test the working condition of the LED, through an independent circuit.
Important: For safety, please use a protection resistor in this circuit.

Depending on the expected state of the light, the program controls whether or not to provide power in pin-18 of the gpio.
When power is provided in the pin, the LED glows (ON State) and when no power is provided on it then it does not glow (OFF state).
Expand All @@ -27,7 +27,7 @@ When power is provided in the pin, the LED glows (ON State) and when no power is
2. GPIO
3. Breadboard along with wires
4. LED light
5. Push Button switch (to test the working condition of the light, this can be skipped if needed)


### Software Prerequisites

Expand Down Expand Up @@ -60,13 +60,13 @@ kubectl apply -f led-light-device-instance.yaml

5. Update the name of the device (device instance name) created using the device CRD in the previous step along with the MQTT URL using which edge_core is running in the configuration file present at
```console
$GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/configuration/config.yaml
$GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/light_mapper/configuration/config.yaml
```

6. Build the mapper to run in RaspBerry-Pi.

```shell
cd $GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/
cd $GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/light_mapper
make # or `make led_light_mapper`
docker tag led-light-mapper:v1.1 <your_dockerhub_username>/led-light-mapper:v1.1
docker push <your_dockerhub_username>/led-light-mapper:v1.1
Expand All @@ -82,7 +82,7 @@ docker login
7. Deploy the light mapper.

```console
cd $GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/
cd $GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/light_mapper

# Please enter the following details in the deployment.yaml :-
# 1. Replace <edge_node_name> with the name of your edge node at spec.template.spec.voluems.configMap.name
Expand All @@ -95,4 +95,34 @@ kubectl create -f deployment.yaml
"OFF" to turn off the light using the device CRDs. The mapper will control the LED to match the state mentioned in the cloud and also report back
the actual state of the light to the cloud after updating.

## A New Way to Control in Web
<img src="images/raspberry-pi.gif">

1. Build the web-controller-app

```console
cd $GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/web-controller-app
make
docker tag kubeedge/kubeedge-counter-app:v1.0.0 <your_dockerhub_username>/kubeedge-counter-app:v1.0.0
docker push <your_dockerhub_username>/kubeedge-counter-app:v1.0.0

# Note: Before trying to push the docker image to the remote repository please ensure that you have signed into docker from your node, if not please type the followig command to sign in

docker login

# Please enter your username and password when prompted
```

2. Deploy the light mapper.

```console
cd $GOPATH/src/github.com/kubeedge/examples/led-raspberrypi/crds

# Please enter the following details in the kubeedge-web-controller-app.yaml :-
# 1. Replace <edge_node_name> with the name of your edge node at spec.template.spec.voluems.configMap.name
# 2. Replace <your_dockerhub_username> with your dockerhub username at spec.template.spec.containers.image

kubectl create -f kubeedge-web-controller-app.yaml
```

3. Change Status in your web app link `MASTER_NODE_IP:80`.
57 changes: 57 additions & 0 deletions led-raspberrypi/crds/kubeedge-web-controller-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: kubeedge-counter-app
name: kubeedge-counter-app
namespace: default
spec:
selector:
matchLabels:
k8s-app: kubeedge-counter-app
template:
metadata:
labels:
k8s-app: kubeedge-counter-app
spec:
nodeSelector:
node-role.kubernetes.io/master: ""
containers:
- name: kubeedge-counter-app
image: <your_dockerhub_username>/kubeedge-counter-app:v1.0.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
hostPort: 80
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
restartPolicy: Always
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: kubeedge-counter
namespace: default
rules:
- apiGroups: ["devices.kubeedge.io"]
resources: ["devices"]
verbs: ["get", "patch"]

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: kubeedge-counter-rbac
namespace: default
subjects:
- kind: ServiceAccount
name: default
roleRef:
kind: Role
name: kubeedge-counter
apiGroup: rbac.authorization.k8s.io
Binary file modified led-raspberrypi/images/raspberry-pi-wiring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added led-raspberrypi/images/raspberry-pi.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added led-raspberrypi/images/raspberry-pi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed led-raspberrypi/images/raspberry-pi.png
Binary file not shown.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.14
require (
github.com/eclipse/paho.mqtt.golang v1.3.1
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/stianeikeland/go-rpio v4.2.0+incompatible
github.com/stianeikeland/go-rpio/v4 v4.6.0
gopkg.in/yaml.v2 v2.4.0
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekf
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/stianeikeland/go-rpio v4.2.0+incompatible h1:CUOlIxdJdT+H1obJPsmg8byu7jMSECLfAN9zynm5QGo=
github.com/stianeikeland/go-rpio v4.2.0+incompatible/go.mod h1:Sh81rdJwD96E2wja2Gd7rrKM+XZ9LrwvN2w4IXrqLR8=
github.com/stianeikeland/go-rpio/v4 v4.6.0 h1:eAJgtw3jTtvn/CqwbC82ntcS+dtzUTgo5qlZKe677EY=
github.com/stianeikeland/go-rpio/v4 v4.6.0/go.mod h1:A3GvHxC1Om5zaId+HqB3HKqx4K/AqeckxB7qRjxMK7o=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"

"github.com/golang/glog"
"github.com/stianeikeland/go-rpio"
"github.com/stianeikeland/go-rpio/v4"
)

func TurnON(pinNumber int64) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading